{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: duckdb in /usr/local/lib/python3.9/dist-packages (1.0.0)\n",
      "Collecting duckdb\n",
      "  Using cached duckdb-1.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.5 MB)\n",
      "  Using cached duckdb-0.10.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.5 MB)\n",
      "Requirement already satisfied: pandas in /usr/local/lib/python3.9/dist-packages (2.2.2)\n",
      "Collecting pandas\n",
      "  Using cached pandas-2.2.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.1 MB)\n",
      "  Using cached pandas-2.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.0 MB)\n",
      "Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.9/dist-packages (from pandas) (2.8.2)\n",
      "Requirement already satisfied: numpy>=1.22.4 in /usr/local/lib/python3.9/dist-packages (from pandas) (1.24.2)\n",
      "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.9/dist-packages (from pandas) (2022.7)\n",
      "Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.9/dist-packages (from pandas) (2023.3)\n",
      "Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.8.2->pandas) (1.16.0)\n",
      "Requirement already satisfied: polars in /usr/local/lib/python3.9/dist-packages (1.5.0)\n",
      "Collecting polars\n",
      "  Using cached polars-1.5.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (31.6 MB)\n",
      "  Using cached polars-1.4.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (31.5 MB)\n",
      "Requirement already satisfied: chdb>=2.0.0b1 in /usr/local/lib/python3.9/dist-packages (2.0.0b1)\n",
      "Collecting chdb>=2.0.0b1\n",
      "  Using cached chdb-2.0.0b1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (134.8 MB)\n",
      "Name: chdb\n",
      "Version: 2.0.0b1\n",
      "Summary: chDB is an in-process SQL OLAP Engine powered by ClickHouse\n",
      "Home-page: https://github.com/chdb-io/chdb\n",
      "Author: auxten\n",
      "Author-email: auxten@clickhouse.com\n",
      "License: Apache-2.0\n",
      "Location: /usr/local/lib/python3.9/dist-packages\n",
      "Requires: \n",
      "Required-by: \n"
     ]
    }
   ],
   "source": [
    "!pip install -U duckdb\n",
    "!pip install -U pandas\n",
    "!pip install -U polars\n",
    "!pip install -U 'chdb>=2.0.0b1'\n",
    "!pip show chdb"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# prepare data\n",
    "import os\n",
    "import chdb\n",
    "\n",
    "if not os.path.exists(\"/tmp/hits.parquet\"):\n",
    "    !wget \"https://datasets.clickhouse.com/hits_compatible/athena/hits.parquet\" -O /tmp/hits.parquet\n",
    "\n",
    "# # 1/100 of the data, for testing\n",
    "if not os.path.exists(\"/tmp/hits_0.parquet\"):\n",
    "    !wget \"https://datasets.clickhouse.com/hits_compatible/athena_partitioned/hits_0.parquet\" -O /tmp/hits_0.parquet\n",
    "\n",
    "# # 10m rows of ClickBench data\n",
    "if not os.path.exists(\"/tmp/hits10m.parquet\"):\n",
    "    chdb.query(\"SELECT * FROM `/tmp/hits.parquet` LIMIT 10000000 INTO OUTFILE '/tmp/hits10m.parquet'\").show()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-rw-r--r-- 1 root root 880M Aug 19 11:34 /tmp/hits10m.parquet\n",
      "-rw-r--r-- 1 root root 117M Jul  3  2022 /tmp/hits_0.parquet\n",
      "Read parquet file into memory. Time cost: 0.47272610664367676 s\n",
      "Parquet file size: 922699018 bytes\n",
      "Read parquet file as old pandas dataframe. Time cost: 10.32185673713684 s\n",
      "Dataframe(numpy) size: 4700000128 bytes\n"
     ]
    }
   ],
   "source": [
    "#!python3\n",
    "\n",
    "import os\n",
    "import time\n",
    "import datetime\n",
    "import chdb\n",
    "import chdb.dataframe as cdf\n",
    "import chdb.session as chs\n",
    "import pandas as pd\n",
    "import duckdb\n",
    "# import numpy as np\n",
    "# import pyarrow as pa\n",
    "# import pyarrow.parquet as pq\n",
    "\n",
    "\n",
    "\n",
    "!ls -lh /tmp/hits10m.parquet\n",
    "!ls -lh /tmp/hits_0.parquet\n",
    "\n",
    "hits_data = \"/tmp/hits10m.parquet\"\n",
    "# hits_data = \"/tmp/hits_0.parquet\"\n",
    "\n",
    "t = time.time()\n",
    "# read parquet file into memory\n",
    "with open(hits_data, \"rb\") as f:\n",
    "    data = f.read()\n",
    "print(\"Read parquet file into memory. Time cost:\", time.time() - t, \"s\")\n",
    "print(\"Parquet file size:\", len(data), \"bytes\")\n",
    "del data\n",
    "\n",
    "# read parquet file as old pandas dataframe\n",
    "t = time.time()\n",
    "hits = pd.read_parquet(hits_data)\n",
    "print(\"Read parquet file as old pandas dataframe. Time cost:\", time.time() - t, \"s\")\n",
    "print(\"Dataframe(numpy) size:\", hits.memory_usage().sum(), \"bytes\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "WatchID                 int64\n",
       "JavaEnable              int16\n",
       "Title                  object\n",
       "GoodEvent               int16\n",
       "EventTime      datetime64[ns]\n",
       "                    ...      \n",
       "FromTag                object\n",
       "HasGCLID                int16\n",
       "RefererHash             int64\n",
       "URLHash                 int64\n",
       "CLID                    int32\n",
       "Length: 105, dtype: object"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# fix some types\n",
    "# print(hits[\"EventTime\"][0:10])\n",
    "hits[\"EventTime\"] = pd.to_datetime(hits[\"EventTime\"], unit=\"s\")\n",
    "# print(hits[\"EventTime\"][0:10])\n",
    "\n",
    "hits[\"EventDate\"] = pd.to_datetime(hits[\"EventDate\"], unit=\"D\")\n",
    "# print(hits[\"EventDate\"][0:10])\n",
    "\n",
    "# fix all object columns to string\n",
    "for col in hits.columns:\n",
    "    if hits[col].dtype == \"O\":\n",
    "        # hits[col] = hits[col].astype('string')\n",
    "        hits[col] = hits[col].astype(str)\n",
    "\n",
    "title = hits[\"Title\"]\n",
    "\n",
    "hits.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Convert dataframe to polars dataframe. Time cost: 22.842999935150146 s\n"
     ]
    }
   ],
   "source": [
    "# convert dataframe to numpy array\n",
    "import polars as pl\n",
    "\n",
    "t = time.time()\n",
    "pl_df = pl.DataFrame(hits)\n",
    "pl_load_time = time.time() - t\n",
    "print(\"Convert dataframe to polars dataframe. Time cost:\", pl_load_time, \"s\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "class myReader(chdb.PyReader):\n",
    "    def __init__(self, data):\n",
    "        self.data = data\n",
    "        self.cursor = 0\n",
    "        super().__init__(data)\n",
    "\n",
    "    def read(self, col_names, count):\n",
    "        # print(\"read\", col_names, count)\n",
    "        # get the columns from the data with col_names\n",
    "        block = [self.data[col] for col in col_names]\n",
    "        # print(\"columns and rows\", len(block), len(block[0]))\n",
    "        # get the data from the cursor to cursor + count\n",
    "        block = [col[self.cursor : self.cursor + count] for col in block]\n",
    "        # print(\"columns and rows\", len(block), len(block[0]))\n",
    "        # move the cursor\n",
    "        self.cursor += block[0].shape[0]\n",
    "        return block"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "queries = [\n",
    "    (\"Q0\", \"SELECT COUNT(*) FROM hits;\", lambda x: x.count(), lambda x: x.height),\n",
    "    (\n",
    "        \"Q1\",\n",
    "        \"SELECT COUNT(*) FROM hits WHERE AdvEngineID <> 0;\",\n",
    "        lambda x: x[x[\"AdvEngineID\"] != 0].count(),\n",
    "        lambda x: x.filter(pl.col(\"AdvEngineID\") != 0).height,\n",
    "    ),\n",
    "    (\n",
    "        \"Q2\",\n",
    "        \"SELECT SUM(AdvEngineID), COUNT(*), AVG(ResolutionWidth) FROM hits;\",\n",
    "        lambda x: (x[\"AdvEngineID\"].sum(), x.shape[0], x[\"ResolutionWidth\"].mean()),\n",
    "        lambda x: (x[\"AdvEngineID\"].sum(), x.height, x[\"ResolutionWidth\"].mean()),\n",
    "    ),\n",
    "    (\n",
    "        \"Q3\",\n",
    "        \"SELECT AVG(UserID) FROM hits;\",\n",
    "        lambda x: x[\"UserID\"].mean(),\n",
    "        lambda x: x[\"UserID\"].mean(),\n",
    "    ),\n",
    "    (\n",
    "        \"Q4\",\n",
    "        \"SELECT COUNT(DISTINCT UserID) FROM hits;\",\n",
    "        lambda x: x[\"UserID\"].nunique(),\n",
    "        lambda x: x[\"UserID\"].n_unique(),\n",
    "    ),\n",
    "    (\n",
    "        \"Q5\",\n",
    "        \"SELECT COUNT(DISTINCT SearchPhrase) FROM hits;\",\n",
    "        lambda x: x[\"SearchPhrase\"].nunique(),\n",
    "        lambda x: x[\"SearchPhrase\"].n_unique(),\n",
    "    ),\n",
    "    (\n",
    "        \"Q6\",\n",
    "        \"SELECT MIN(EventDate), MAX(EventDate) FROM hits;\",\n",
    "        lambda x: (x[\"EventDate\"].min(), x[\"EventDate\"].max()),\n",
    "        lambda x: (x[\"EventDate\"].min(), x[\"EventDate\"].max()),\n",
    "    ),\n",
    "    (\n",
    "        \"Q7\",\n",
    "        \"SELECT AdvEngineID, COUNT(*) FROM hits WHERE AdvEngineID <> 0 GROUP BY AdvEngineID ORDER BY COUNT(*) DESC;\",\n",
    "        lambda x: x[x[\"AdvEngineID\"] != 0]\n",
    "        .groupby(\"AdvEngineID\")\n",
    "        .size()\n",
    "        .sort_values(ascending=False),\n",
    "        lambda x: x.filter(pl.col(\"AdvEngineID\") != 0)\n",
    "        .group_by(\"AdvEngineID\")\n",
    "        .agg(pl.len().alias(\"count\"))\n",
    "        .sort(\"count\", descending=True),\n",
    "    ),\n",
    "    (\n",
    "        \"Q8\",\n",
    "        \"SELECT RegionID, COUNT(DISTINCT UserID) AS u FROM hits GROUP BY RegionID ORDER BY u DESC LIMIT 10;\",\n",
    "        lambda x: x.groupby(\"RegionID\")[\"UserID\"].nunique().nlargest(10),\n",
    "        lambda x: x.group_by(\"RegionID\")\n",
    "        .agg(pl.col(\"UserID\").n_unique())\n",
    "        .sort(\"UserID\", descending=True)\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q9\",\n",
    "        \"SELECT RegionID, SUM(AdvEngineID), COUNT(*) AS c, AVG(ResolutionWidth), COUNT(DISTINCT UserID) FROM hits GROUP BY RegionID ORDER BY c DESC LIMIT 10;\",\n",
    "        lambda x: x.groupby(\"RegionID\")\n",
    "        .agg({\"AdvEngineID\": \"sum\", \"ResolutionWidth\": \"mean\", \"UserID\": \"nunique\"})\n",
    "        .nlargest(10, \"AdvEngineID\"),\n",
    "        lambda x: x.group_by(\"RegionID\")\n",
    "        .agg(\n",
    "            [\n",
    "                pl.sum(\"AdvEngineID\").alias(\"AdvEngineID_sum\"),\n",
    "                pl.mean(\"ResolutionWidth\").alias(\"ResolutionWidth_mean\"),\n",
    "                pl.col(\"UserID\").n_unique().alias(\"UserID_nunique\"),\n",
    "            ]\n",
    "        )\n",
    "        .sort(\"AdvEngineID_sum\", descending=True)\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q10\",\n",
    "        \"SELECT MobilePhoneModel, COUNT(DISTINCT UserID) AS u FROM hits WHERE MobilePhoneModel <> '' GROUP BY MobilePhoneModel ORDER BY u DESC LIMIT 10;\",\n",
    "        lambda x: x[x[\"MobilePhoneModel\"] != \"\"]\n",
    "        .groupby(\"MobilePhoneModel\")[\"UserID\"]\n",
    "        .nunique()\n",
    "        .nlargest(10),\n",
    "        lambda x: x.filter(pl.col(\"MobilePhoneModel\") != \"\")\n",
    "        .group_by(\"MobilePhoneModel\")\n",
    "        .agg(pl.col(\"UserID\").n_unique())\n",
    "        .sort(\"UserID\", descending=True)\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q11\",\n",
    "        \"SELECT MobilePhone, MobilePhoneModel, COUNT(DISTINCT UserID) AS u FROM hits WHERE MobilePhoneModel <> '' GROUP BY MobilePhone, MobilePhoneModel ORDER BY u DESC LIMIT 10;\",\n",
    "        lambda x: x[x[\"MobilePhoneModel\"] != \"\"]\n",
    "        .groupby([\"MobilePhone\", \"MobilePhoneModel\"])[\"UserID\"]\n",
    "        .nunique()\n",
    "        .nlargest(10),\n",
    "        lambda x: x.filter(pl.col(\"MobilePhoneModel\") != \"\")\n",
    "        .group_by([\"MobilePhone\", \"MobilePhoneModel\"])\n",
    "        .agg(pl.col(\"UserID\").n_unique())\n",
    "        .sort(\"UserID\", descending=True)\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q12\",\n",
    "        \"SELECT SearchPhrase, COUNT(*) AS c FROM hits WHERE SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY c DESC LIMIT 10;\",\n",
    "        lambda x: x[x[\"SearchPhrase\"] != \"\"]\n",
    "        .groupby(\"SearchPhrase\")\n",
    "        .size()\n",
    "        .nlargest(10),\n",
    "        lambda x: x.filter(pl.col(\"SearchPhrase\") != \"\")\n",
    "        .group_by(\"SearchPhrase\")\n",
    "        .agg(pl.len().alias(\"count\"))\n",
    "        .sort(\"count\", descending=True)\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q13\",\n",
    "        \"SELECT SearchPhrase, COUNT(DISTINCT UserID) AS u FROM hits WHERE SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY u DESC LIMIT 10;\",\n",
    "        lambda x: x[x[\"SearchPhrase\"] != \"\"]\n",
    "        .groupby(\"SearchPhrase\")[\"UserID\"]\n",
    "        .nunique()\n",
    "        .nlargest(10),\n",
    "        lambda x: x.filter(pl.col(\"SearchPhrase\") != \"\")\n",
    "        .group_by(\"SearchPhrase\")\n",
    "        .agg(pl.col(\"UserID\").n_unique())\n",
    "        .sort(\"UserID\", descending=True)\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q14\",\n",
    "        \"SELECT SearchEngineID, SearchPhrase, COUNT(*) AS c FROM hits WHERE SearchPhrase <> '' GROUP BY SearchEngineID, SearchPhrase ORDER BY c DESC LIMIT 10;\",\n",
    "        lambda x: x[x[\"SearchPhrase\"] != \"\"]\n",
    "        .groupby([\"SearchEngineID\", \"SearchPhrase\"])\n",
    "        .size()\n",
    "        .nlargest(10),\n",
    "        lambda x: x.filter(pl.col(\"SearchPhrase\") != \"\")\n",
    "        .group_by([\"SearchEngineID\", \"SearchPhrase\"])\n",
    "        .agg(pl.len().alias(\"count\"))\n",
    "        .sort(\"count\", descending=True)\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q15\",\n",
    "        \"SELECT UserID, COUNT(*) FROM hits GROUP BY UserID ORDER BY COUNT(*) DESC LIMIT 10;\",\n",
    "        lambda x: x.groupby(\"UserID\").size().nlargest(10),\n",
    "        lambda x: x.group_by(\"UserID\")\n",
    "        .agg(pl.len().alias(\"count\"))\n",
    "        .sort(\"count\", descending=True)\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q16\",\n",
    "        \"SELECT UserID, SearchPhrase, COUNT(*) FROM hits GROUP BY UserID, SearchPhrase ORDER BY COUNT(*) DESC LIMIT 10;\",\n",
    "        lambda x: x.groupby([\"UserID\", \"SearchPhrase\"]).size().nlargest(10),\n",
    "        lambda x: x.group_by([\"UserID\", \"SearchPhrase\"])\n",
    "        .agg(pl.len().alias(\"count\"))\n",
    "        .sort(\"count\", descending=True)\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q17\",\n",
    "        \"SELECT UserID, SearchPhrase, COUNT(*) FROM hits GROUP BY UserID, SearchPhrase LIMIT 10;\",\n",
    "        lambda x: x.groupby([\"UserID\", \"SearchPhrase\"]).size().head(10),\n",
    "        lambda x: x.group_by([\"UserID\", \"SearchPhrase\"]).agg(pl.len()).head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q18\",\n",
    "        \"SELECT UserID, extract(minute FROM EventTime) AS m, SearchPhrase, COUNT(*) FROM hits GROUP BY UserID, m, SearchPhrase ORDER BY COUNT(*) DESC LIMIT 10;\",\n",
    "        lambda x: x.groupby([x[\"UserID\"], x[\"EventTime\"].dt.minute, \"SearchPhrase\"])\n",
    "        .size()\n",
    "        .nlargest(10),\n",
    "        lambda x: x.group_by(\n",
    "            [pl.col(\"UserID\"), x[\"EventTime\"].dt.minute(), \"SearchPhrase\"]\n",
    "        )\n",
    "        .agg(pl.len().alias(\"count\"))\n",
    "        .sort(\"count\", descending=True)\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q19\",\n",
    "        \"SELECT UserID FROM hits WHERE UserID = 435090932899640449;\",\n",
    "        lambda x: x[x[\"UserID\"] == 435090932899640449],\n",
    "        lambda x: x.filter(pl.col(\"UserID\") == 435090932899640449),\n",
    "    ),\n",
    "    (\n",
    "        \"Q20\",\n",
    "        \"SELECT COUNT(*) FROM hits WHERE URL LIKE '%google%';\",\n",
    "        lambda x: x[x[\"URL\"].str.contains(\"google\")].shape[0],\n",
    "        lambda x: x.filter(pl.col(\"URL\").str.contains(\"google\")).height,\n",
    "    ),\n",
    "    (\n",
    "        \"Q21\",\n",
    "        \"SELECT SearchPhrase, MIN(URL), COUNT(*) AS c FROM hits WHERE URL LIKE '%google%' AND SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY c DESC LIMIT 10;\",\n",
    "        lambda x: x[(x[\"URL\"].str.contains(\"google\")) & (x[\"SearchPhrase\"] != \"\")]\n",
    "        .groupby(\"SearchPhrase\")\n",
    "        .agg({\"URL\": \"min\", \"SearchPhrase\": \"size\"})\n",
    "        .nlargest(10, \"SearchPhrase\"),\n",
    "        lambda x: x.filter(\n",
    "            (pl.col(\"URL\").str.contains(\"google\")) & (pl.col(\"SearchPhrase\") != \"\")\n",
    "        )\n",
    "        .group_by(\"SearchPhrase\")\n",
    "        .agg([pl.col(\"URL\").min(), pl.len().alias(\"count\")])\n",
    "        .sort(\"count\", descending=True)\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q22\",\n",
    "        \"SELECT SearchPhrase, MIN(URL), MIN(Title), COUNT(*) AS c, COUNT(DISTINCT UserID) FROM hits WHERE Title LIKE '%Google%' AND URL NOT LIKE '%.google.%' AND SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY c DESC LIMIT 10;\",\n",
    "        lambda x: x[\n",
    "            (x[\"Title\"].str.contains(\"Google\"))\n",
    "            & (~x[\"URL\"].str.contains(\".google.\"))\n",
    "            & (x[\"SearchPhrase\"] != \"\")\n",
    "        ]\n",
    "        .groupby(\"SearchPhrase\")\n",
    "        .agg(\n",
    "            {\"URL\": \"min\", \"Title\": \"min\", \"SearchPhrase\": \"size\", \"UserID\": \"nunique\"}\n",
    "        )\n",
    "        .nlargest(10, \"SearchPhrase\"),\n",
    "        lambda x: x.filter(\n",
    "            (pl.col(\"Title\").str.contains(\"Google\"))\n",
    "            & (~pl.col(\"URL\").str.contains(\".google.\"))\n",
    "            & (pl.col(\"SearchPhrase\") != \"\")\n",
    "        )\n",
    "        .group_by(\"SearchPhrase\")\n",
    "        .agg(\n",
    "            [\n",
    "                pl.col(\"URL\").min(),\n",
    "                pl.col(\"Title\").min(),\n",
    "                pl.len().alias(\"count\"),\n",
    "                pl.col(\"UserID\").n_unique(),\n",
    "            ]\n",
    "        )\n",
    "        .sort(\"count\", descending=True)\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q23\",\n",
    "        \"SELECT * FROM hits WHERE URL LIKE '%google%' ORDER BY EventTime LIMIT 10;\",\n",
    "        lambda x: x[x[\"URL\"].str.contains(\"google\")]\n",
    "        .sort_values(by=\"EventTime\")\n",
    "        .head(10),\n",
    "        lambda x: x.filter(pl.col(\"URL\").str.contains(\"google\"))\n",
    "        .sort(\"EventTime\")\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q24\",\n",
    "        \"SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY EventTime LIMIT 10;\",\n",
    "        lambda x: x[x[\"SearchPhrase\"] != \"\"]\n",
    "        .sort_values(by=\"EventTime\")[[\"SearchPhrase\"]]\n",
    "        .head(10),\n",
    "        lambda x: x.filter(pl.col(\"SearchPhrase\") != \"\")\n",
    "        .sort(\"EventTime\")\n",
    "        .select(\"SearchPhrase\")\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q25\",\n",
    "        \"SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY SearchPhrase LIMIT 10;\",\n",
    "        lambda x: x[x[\"SearchPhrase\"] != \"\"]\n",
    "        .sort_values(by=\"SearchPhrase\")[[\"SearchPhrase\"]]\n",
    "        .head(10),\n",
    "        lambda x: x.filter(pl.col(\"SearchPhrase\") != \"\")\n",
    "        .sort(\"SearchPhrase\")\n",
    "        .select(\"SearchPhrase\")\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q26\",\n",
    "        \"SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY EventTime, SearchPhrase LIMIT 10;\",\n",
    "        lambda x: x[x[\"SearchPhrase\"] != \"\"]\n",
    "        .sort_values(by=[\"EventTime\", \"SearchPhrase\"])[[\"SearchPhrase\"]]\n",
    "        .head(10),\n",
    "        lambda x: x.filter(pl.col(\"SearchPhrase\") != \"\")\n",
    "        .sort([\"EventTime\", \"SearchPhrase\"])\n",
    "        .select(\"SearchPhrase\")\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q27\",\n",
    "        \"SELECT CounterID, AVG(STRLEN(URL)) AS l, COUNT(*) AS c FROM hits WHERE URL <> '' GROUP BY CounterID HAVING COUNT(*) > 100000 ORDER BY l DESC LIMIT 25;\",\n",
    "        lambda x: x[x[\"URL\"] != \"\"]\n",
    "        .groupby(\"CounterID\")\n",
    "        .filter(lambda g: g[\"URL\"].count() > 100000)\n",
    "        .agg({\"URL\": lambda url: url.str.len().mean(), \"CounterID\": \"size\"})\n",
    "        .sort_values()\n",
    "        .head(25),\n",
    "        lambda x: x.filter(pl.col(\"URL\") != \"\")  # WHERE URL <> ''\n",
    "        .group_by(\"CounterID\")  # GROUP BY CounterID\n",
    "        .agg(\n",
    "            [\n",
    "                pl.col(\"URL\")\n",
    "                .map_elements(lambda y: len(y), return_dtype=pl.Int64)\n",
    "                .alias(\"l\"),  # AVG(STRLEN(URL))\n",
    "                pl.len().alias(\"c\"),  # COUNT(*)\n",
    "            ]\n",
    "        )\n",
    "        .filter(pl.col(\"c\") > 100000)  # HAVING COUNT(*) > 100000\n",
    "        .sort(\"l\", descending=True)  # ORDER BY l DESC\n",
    "        .limit(25),  # LIMIT 25,\n",
    "    ),\n",
    "    (\n",
    "        \"Q28\",\n",
    "        \"SELECT REGEXP_REPLACE(Referer, '^https?://(?:www\\\\.)?([^/]+)/.*$', '\\\\1') AS k, AVG(STRLEN(Referer)) AS l, COUNT(*) AS c, MIN(Referer) FROM hits WHERE Referer <> '' GROUP BY k HAVING COUNT(*) > 100000 ORDER BY l DESC LIMIT 25;\",\n",
    "        lambda x: (\n",
    "            x[x[\"Referer\"] != \"\"]\n",
    "            .assign(k=x[\"Referer\"].str.extract(r\"^https?://(?:www\\.)?([^/]+)/.*$\")[0])\n",
    "            .groupby(\"k\")\n",
    "            .filter(lambda g: g[\"Referer\"].count() > 100000)\n",
    "            .agg(\n",
    "                min_referer=(\"Referer\", \"min\"),\n",
    "                average_length=(\"Referer\", lambda r: r.str.len().mean()),\n",
    "            )\n",
    "            .head(25)\n",
    "        ),\n",
    "        lambda x: (\n",
    "            x.filter(pl.col(\"Referer\") != \"\")\n",
    "            .with_columns(\n",
    "                pl.col(\"Referer\")\n",
    "                .str.extract(r\"^https?://(?:www\\\\.)?([^/]+)/.*$\")\n",
    "                .alias(\"k\")\n",
    "            )\n",
    "            .group_by(\"k\")\n",
    "            .agg(\n",
    "                [\n",
    "                    pl.col(\"Referer\")\n",
    "                    .map_elements(lambda y: len(y), return_dtype=pl.Int64)\n",
    "                    # .mean() # skip mean for now\n",
    "                    .alias(\"l\"),  # AVG(STRLEN(Referer))\n",
    "                    pl.col(\"Referer\").min().alias(\"min_referer\"),  # MIN(Referer)\n",
    "                    pl.len().alias(\"c\"),  # COUNT(*)\n",
    "                ]\n",
    "            )\n",
    "            .filter(pl.col(\"c\") > 100000)  # HAVING COUNT(*) > 100000\n",
    "            .sort(\"l\", descending=True)  # ORDER BY l DESC\n",
    "            .limit(25)  # LIMIT 25\n",
    "        ),\n",
    "    ),\n",
    "    (\n",
    "        \"Q29\",\n",
    "        \"SELECT SUM(ResolutionWidth), SUM(ResolutionWidth + 1), SUM(ResolutionWidth + 2), SUM(ResolutionWidth + 3), SUM(ResolutionWidth + 4), SUM(ResolutionWidth + 5), SUM(ResolutionWidth + 6), SUM(ResolutionWidth + 7), SUM(ResolutionWidth + 8), SUM(ResolutionWidth + 9), SUM(ResolutionWidth + 10), SUM(ResolutionWidth + 11), SUM(ResolutionWidth + 12), SUM(ResolutionWidth + 13), SUM(ResolutionWidth + 14), SUM(ResolutionWidth + 15), SUM(ResolutionWidth + 16), SUM(ResolutionWidth + 17), SUM(ResolutionWidth + 18), SUM(ResolutionWidth + 19), SUM(ResolutionWidth + 20), SUM(ResolutionWidth + 21), SUM(ResolutionWidth + 22), SUM(ResolutionWidth + 23), SUM(ResolutionWidth + 24), SUM(ResolutionWidth + 25), SUM(ResolutionWidth + 26), SUM(ResolutionWidth + 27), SUM(ResolutionWidth + 28), SUM(ResolutionWidth + 29), SUM(ResolutionWidth + 30), SUM(ResolutionWidth + 31), SUM(ResolutionWidth + 32), SUM(ResolutionWidth + 33), SUM(ResolutionWidth + 34), SUM(ResolutionWidth + 35), SUM(ResolutionWidth + 36), SUM(ResolutionWidth + 37), SUM(ResolutionWidth + 38), SUM(ResolutionWidth + 39), SUM(ResolutionWidth + 40), SUM(ResolutionWidth + 41), SUM(ResolutionWidth + 42), SUM(ResolutionWidth + 43), SUM(ResolutionWidth + 44), SUM(ResolutionWidth + 45), SUM(ResolutionWidth + 46), SUM(ResolutionWidth + 47), SUM(ResolutionWidth + 48), SUM(ResolutionWidth + 49), SUM(ResolutionWidth + 50), SUM(ResolutionWidth + 51), SUM(ResolutionWidth + 52), SUM(ResolutionWidth + 53), SUM(ResolutionWidth + 54), SUM(ResolutionWidth + 55), SUM(ResolutionWidth + 56), SUM(ResolutionWidth + 57), SUM(ResolutionWidth + 58), SUM(ResolutionWidth + 59), SUM(ResolutionWidth + 60), SUM(ResolutionWidth + 61), SUM(ResolutionWidth + 62), SUM(ResolutionWidth + 63), SUM(ResolutionWidth + 64), SUM(ResolutionWidth + 65), SUM(ResolutionWidth + 66), SUM(ResolutionWidth + 67), SUM(ResolutionWidth + 68), SUM(ResolutionWidth + 69), SUM(ResolutionWidth + 70), SUM(ResolutionWidth + 71), SUM(ResolutionWidth + 72), SUM(ResolutionWidth + 73), SUM(ResolutionWidth + 74), SUM(ResolutionWidth + 75), SUM(ResolutionWidth + 76), SUM(ResolutionWidth + 77), SUM(ResolutionWidth + 78), SUM(ResolutionWidth + 79), SUM(ResolutionWidth + 80), SUM(ResolutionWidth + 81), SUM(ResolutionWidth + 82), SUM(ResolutionWidth + 83), SUM(ResolutionWidth + 84), SUM(ResolutionWidth + 85), SUM(ResolutionWidth + 86), SUM(ResolutionWidth + 87), SUM(ResolutionWidth + 88), SUM(ResolutionWidth + 89) FROM hits;\",\n",
    "        lambda x: x[\"ResolutionWidth\"].sum()\n",
    "        + x[\"ResolutionWidth\"].shift(1).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(2).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(3).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(4).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(5).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(6).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(7).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(8).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(9).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(10).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(11).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(12).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(13).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(14).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(15).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(16).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(17).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(18).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(19).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(20).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(21).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(22).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(23).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(24).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(25).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(26).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(27).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(28).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(29).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(30).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(31).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(32).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(33).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(34).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(35).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(36).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(37).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(38).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(39).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(40).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(41).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(42).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(43).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(44).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(45).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(46).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(47).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(48).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(49).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(50).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(51).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(52).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(53).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(54).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(55).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(56).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(57).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(58).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(59).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(60).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(61).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(62).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(63).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(64).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(65).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(66).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(67).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(68).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(69).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(70).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(71).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(72).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(73).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(74).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(75).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(76).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(77).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(78).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(79).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(80).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(81).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(82).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(83).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(84).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(85).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(86).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(87).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(88).sum()\n",
    "        + x[\"ResolutionWidth\"].shift(89).sum(),\n",
    "        lambda x: sum(x[\"ResolutionWidth\"][:90] + pl.Series(range(90))),\n",
    "    ),\n",
    "    (\n",
    "        \"Q30\",\n",
    "        \"SELECT SearchEngineID, ClientIP, COUNT(*) AS c, SUM(IsRefresh), AVG(ResolutionWidth) FROM hits WHERE SearchPhrase <> '' GROUP BY SearchEngineID, ClientIP ORDER BY c DESC LIMIT 10;\",\n",
    "        lambda x: x[x[\"SearchPhrase\"] != \"\"]\n",
    "        .groupby([\"SearchEngineID\", \"ClientIP\"])\n",
    "        .agg(\n",
    "            c=(\"SearchEngineID\", \"size\"),\n",
    "            IsRefreshSum=(\"IsRefresh\", \"sum\"),\n",
    "            AvgResolutionWidth=(\"ResolutionWidth\", \"mean\"),\n",
    "        )\n",
    "        .nlargest(10, \"c\"),\n",
    "        lambda x: x.filter(pl.col(\"SearchPhrase\") != \"\")\n",
    "        .group_by([\"SearchEngineID\", \"ClientIP\"])\n",
    "        .agg(\n",
    "            [\n",
    "                pl.len().alias(\"c\"),\n",
    "                pl.sum(\"IsRefresh\").alias(\"IsRefreshSum\"),\n",
    "                pl.mean(\"ResolutionWidth\").alias(\"AvgResolutionWidth\"),\n",
    "            ]\n",
    "        )\n",
    "        .sort(\"c\", descending=True)\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q31\",\n",
    "        \"SELECT WatchID, ClientIP, COUNT(*) AS c, SUM(IsRefresh), AVG(ResolutionWidth) FROM hits WHERE SearchPhrase <> '' GROUP BY WatchID, ClientIP ORDER BY c DESC LIMIT 10;\",\n",
    "        lambda x: x[x[\"SearchPhrase\"] != \"\"]\n",
    "        .groupby([\"WatchID\", \"ClientIP\"])\n",
    "        .agg(\n",
    "            c=(\"WatchID\", \"size\"),\n",
    "            IsRefreshSum=(\"IsRefresh\", \"sum\"),\n",
    "            AvgResolutionWidth=(\"ResolutionWidth\", \"mean\"),\n",
    "        )\n",
    "        .nlargest(10, \"c\"),\n",
    "        lambda x: x.filter(pl.col(\"SearchPhrase\") != \"\")\n",
    "        .group_by([\"WatchID\", \"ClientIP\"])\n",
    "        .agg(\n",
    "            [\n",
    "                pl.len().alias(\"c\"),\n",
    "                pl.sum(\"IsRefresh\").alias(\"IsRefreshSum\"),\n",
    "                pl.mean(\"ResolutionWidth\").alias(\"AvgResolutionWidth\"),\n",
    "            ]\n",
    "        )\n",
    "        .sort(\"c\", descending=True)\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q32\",\n",
    "        \"SELECT WatchID, ClientIP, COUNT(*) AS c, SUM(IsRefresh), AVG(ResolutionWidth) FROM hits GROUP BY WatchID, ClientIP ORDER BY c DESC LIMIT 10;\",\n",
    "        lambda x: x.groupby([\"WatchID\", \"ClientIP\"])\n",
    "        .agg(\n",
    "            c=(\"WatchID\", \"size\"),\n",
    "            IsRefreshSum=(\"IsRefresh\", \"sum\"),\n",
    "            AvgResolutionWidth=(\"ResolutionWidth\", \"mean\"),\n",
    "        )\n",
    "        .nlargest(10, \"c\"),\n",
    "        lambda x: x.group_by([\"WatchID\", \"ClientIP\"])\n",
    "        .agg(\n",
    "            [\n",
    "                pl.len().alias(\"c\"),\n",
    "                pl.sum(\"IsRefresh\").alias(\"IsRefreshSum\"),\n",
    "                pl.mean(\"ResolutionWidth\").alias(\"AvgResolutionWidth\"),\n",
    "            ]\n",
    "        )\n",
    "        .sort(\"c\", descending=True)\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q33\",\n",
    "        \"SELECT URL, COUNT(*) AS c FROM hits GROUP BY URL ORDER BY c DESC LIMIT 10;\",\n",
    "        lambda x: x.groupby(\"URL\").size().nlargest(10).reset_index(name=\"c\"),\n",
    "        lambda x: x.group_by(\"URL\")\n",
    "        .agg(pl.len().alias(\"c\"))\n",
    "        .sort(\"c\", descending=True)\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q34\",\n",
    "        \"SELECT 1, URL, COUNT(*) AS c FROM hits GROUP BY 1, URL ORDER BY c DESC LIMIT 10;\",\n",
    "        lambda x: x.groupby([\"URL\"]).size().nlargest(10).reset_index(name=\"c\"),\n",
    "        lambda x: x.group_by(\"URL\")\n",
    "        .agg(pl.len().alias(\"c\"))\n",
    "        .sort(\"c\", descending=True)\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q35\",\n",
    "        \"SELECT ClientIP, ClientIP - 1, ClientIP - 2, ClientIP - 3, COUNT(*) AS c FROM hits GROUP BY ClientIP, ClientIP - 1, ClientIP - 2, ClientIP - 3 ORDER BY c DESC LIMIT 10;\",\n",
    "        lambda x: x.assign(\n",
    "            **{f\"ClientIP_minus_{i}\": x[\"ClientIP\"] - i for i in range(1, 4)}\n",
    "        )\n",
    "        .groupby(\n",
    "            [\"ClientIP\", \"ClientIP_minus_1\", \"ClientIP_minus_2\", \"ClientIP_minus_3\"]\n",
    "        )\n",
    "        .size()\n",
    "        .nlargest(10)\n",
    "        .reset_index(name=\"c\"),\n",
    "        lambda x: x.with_columns([pl.col(\"ClientIP\")])\n",
    "        .group_by(\n",
    "            [\"ClientIP\"]\n",
    "        )\n",
    "        .agg(pl.len().alias(\"c\"))\n",
    "        .sort(\"c\", descending=True)\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q36\",\n",
    "        \"SELECT URL, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND DontCountHits = 0 AND IsRefresh = 0 AND URL <> '' GROUP BY URL ORDER BY PageViews DESC LIMIT 10;\",\n",
    "        lambda x: x[\n",
    "            (x[\"CounterID\"] == 62)\n",
    "            & (x[\"EventDate\"] >= \"2013-07-01\")\n",
    "            & (x[\"EventDate\"] <= \"2013-07-31\")\n",
    "            & (x[\"DontCountHits\"] == 0)\n",
    "            & (x[\"IsRefresh\"] == 0)\n",
    "            & (x[\"URL\"] != \"\")\n",
    "        ]\n",
    "        .groupby(\"URL\")\n",
    "        .size()\n",
    "        .nlargest(10),\n",
    "        lambda x: x.filter(\n",
    "            (pl.col(\"CounterID\") == 62)\n",
    "            & (pl.col(\"EventDate\") >= pl.datetime(2013, 7, 1))\n",
    "            & (pl.col(\"EventDate\") <= pl.datetime(2013, 7, 31))\n",
    "            & (pl.col(\"DontCountHits\") == 0)\n",
    "            & (pl.col(\"IsRefresh\") == 0)\n",
    "            & (pl.col(\"URL\") != \"\")\n",
    "        )\n",
    "        .group_by(\"URL\")\n",
    "        .agg(pl.len().alias(\"PageViews\"))\n",
    "        .sort(\"PageViews\", descending=True)\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q37\",\n",
    "        \"SELECT Title, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND DontCountHits = 0 AND IsRefresh = 0 AND Title <> '' GROUP BY Title ORDER BY PageViews DESC LIMIT 10;\",\n",
    "        lambda x: x[\n",
    "            (x[\"CounterID\"] == 62)\n",
    "            & (x[\"EventDate\"] >= \"2013-07-01\")\n",
    "            & (x[\"EventDate\"] <= \"2013-07-31\")\n",
    "            & (x[\"DontCountHits\"] == 0)\n",
    "            & (x[\"IsRefresh\"] == 0)\n",
    "            & (x[\"Title\"] != \"\")\n",
    "        ]\n",
    "        .groupby(\"Title\")\n",
    "        .size()\n",
    "        .nlargest(10),\n",
    "        lambda x: x.filter(\n",
    "            (pl.col(\"CounterID\") == 62)\n",
    "            & (pl.col(\"EventDate\") >= pl.datetime(2013, 7, 1))\n",
    "            & (pl.col(\"EventDate\") <= pl.datetime(2013, 7, 31))\n",
    "            & (pl.col(\"DontCountHits\") == 0)\n",
    "            & (pl.col(\"IsRefresh\") == 0)\n",
    "            & (pl.col(\"Title\") != \"\")\n",
    "        )\n",
    "        .group_by(\"Title\")\n",
    "        .agg(pl.len().alias(\"PageViews\"))\n",
    "        .sort(\"PageViews\", descending=True)\n",
    "        .head(10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q38\",\n",
    "        \"SELECT URL, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND IsRefresh = 0 AND IsLink <> 0 AND IsDownload = 0 GROUP BY URL ORDER BY PageViews DESC LIMIT 10 OFFSET 1000;\",\n",
    "        lambda x: x[\n",
    "            (x[\"CounterID\"] == 62)\n",
    "            & (x[\"EventDate\"] >= \"2013-07-01\")\n",
    "            & (x[\"EventDate\"] <= \"2013-07-31\")\n",
    "            & (x[\"IsRefresh\"] == 0)\n",
    "            & (x[\"IsLink\"] != 0)\n",
    "            & (x[\"IsDownload\"] == 0)\n",
    "        ]\n",
    "        .groupby(\"URL\")\n",
    "        .size()\n",
    "        .nlargest(10)\n",
    "        .reset_index(name=\"PageViews\")\n",
    "        .iloc[1000:1010],\n",
    "        lambda x: x.filter(\n",
    "            (pl.col(\"CounterID\") == 62)\n",
    "            & (pl.col(\"EventDate\") >= pl.datetime(2013, 7, 1))\n",
    "            & (pl.col(\"EventDate\") <= pl.datetime(2013, 7, 31))\n",
    "            & (pl.col(\"IsRefresh\") == 0)\n",
    "            & (pl.col(\"IsLink\") != 0)\n",
    "            & (pl.col(\"IsDownload\") == 0)\n",
    "        )\n",
    "        .group_by(\"URL\")\n",
    "        .agg(pl.len().alias(\"PageViews\"))\n",
    "        .sort(\"PageViews\", descending=True)\n",
    "        .slice(1000, 10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q39\",\n",
    "        \"SELECT TraficSourceID, SearchEngineID, AdvEngineID, CASE WHEN (SearchEngineID = 0 AND AdvEngineID = 0) THEN Referer ELSE '' END AS Src, URL AS Dst, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND IsRefresh = 0 GROUP BY TraficSourceID, SearchEngineID, AdvEngineID, Src, Dst ORDER BY PageViews DESC LIMIT 10 OFFSET 1000;\",\n",
    "        lambda x: x[\n",
    "            (x[\"CounterID\"] == 62)\n",
    "            & (x[\"EventDate\"] >= \"2013-07-01\")\n",
    "            & (x[\"EventDate\"] <= \"2013-07-31\")\n",
    "            & (x[\"IsRefresh\"] == 0)\n",
    "        ]\n",
    "        .groupby([\"TraficSourceID\", \"SearchEngineID\", \"AdvEngineID\", \"Referer\", \"URL\"])\n",
    "        .size()\n",
    "        .nlargest(10)\n",
    "        .reset_index(name=\"PageViews\")\n",
    "        .iloc[1000:1010],\n",
    "        lambda x: None,\n",
    "        # Crash with:\n",
    "        #   thread '<unnamed>' panicked at crates/polars-time/src/windows/duration.rs:215:21:\n",
    "        #   expected leading integer in the duration string, found m\n",
    "        #   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n",
    "        # lambda x: x.filter(\n",
    "        #     (pl.col(\"CounterID\") == 62)\n",
    "        #     & (pl.col(\"EventDate\") >= pl.datetime(2013, 7, 1))\n",
    "        #     & (pl.col(\"EventDate\") <= pl.datetime(2013, 7, 31))\n",
    "        #     & (pl.col(\"IsRefresh\") == 0)\n",
    "        # )\n",
    "        # .group_by(\n",
    "        #     [\n",
    "        #         \"TraficSourceID\",\n",
    "        #         \"SearchEngineID\",\n",
    "        #         \"AdvEngineID\",\n",
    "        #         # pl.when(pl.col(\"SearchEngineID\").eq(0) & pl.col(\"AdvEngineID\").eq(0))\n",
    "        #         # .then(pl.col(\"Referer\"))\n",
    "        #         # .otherwise(\"\")\n",
    "        #         # .alias(\"Src\"),\n",
    "        #         \"URL\",\n",
    "        #     ]\n",
    "        # )\n",
    "        # .agg(pl.len().alias(\"PageViews\"))\n",
    "        # .sort(\"PageViews\", descending=True)\n",
    "        # .slice(1000, 10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q40\",\n",
    "        \"SELECT URLHash, EventDate, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND IsRefresh = 0 AND TraficSourceID IN (-1, 6) AND RefererHash = 3594120000172545465 GROUP BY URLHash, EventDate ORDER BY PageViews DESC LIMIT 10 OFFSET 100;\",\n",
    "        lambda x: x[\n",
    "            (x[\"CounterID\"] == 62)\n",
    "            & (x[\"EventDate\"] >= \"2013-07-01\")\n",
    "            & (x[\"EventDate\"] <= \"2013-07-31\")\n",
    "            & (x[\"IsRefresh\"] == 0)\n",
    "            & (x[\"TraficSourceID\"].isin([-1, 6]))\n",
    "            & (x[\"RefererHash\"] == 3594120000172545465)\n",
    "        ]\n",
    "        .groupby([\"URLHash\", \"EventDate\"])\n",
    "        .size()\n",
    "        .nlargest(10)\n",
    "        .reset_index(name=\"PageViews\")\n",
    "        .iloc[100:110],\n",
    "        lambda x: x.filter(\n",
    "            (pl.col(\"CounterID\") == 62)\n",
    "            & (pl.col(\"EventDate\") >= pl.datetime(2013, 7, 1))\n",
    "            & (pl.col(\"EventDate\") <= pl.datetime(2013, 7, 31))\n",
    "            & (pl.col(\"IsRefresh\") == 0)\n",
    "            & (pl.col(\"TraficSourceID\").is_in([-1, 6]))\n",
    "            & (pl.col(\"RefererHash\") == 3594120000172545465)\n",
    "        )\n",
    "        .group_by([\"URLHash\", \"EventDate\"])\n",
    "        .agg(pl.len().alias(\"PageViews\"))\n",
    "        .sort(\"PageViews\", descending=True)\n",
    "        .slice(100, 10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q41\",\n",
    "        \"SELECT WindowClientWidth, WindowClientHeight, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND IsRefresh = 0 AND DontCountHits = 0 AND URLHash = 2868770270353813622 GROUP BY WindowClientWidth, WindowClientHeight ORDER BY PageViews DESC LIMIT 10 OFFSET 10000;\",\n",
    "        lambda x: x[\n",
    "            (x[\"CounterID\"] == 62)\n",
    "            & (x[\"EventDate\"] >= \"2013-07-01\")\n",
    "            & (x[\"EventDate\"] <= \"2013-07-31\")\n",
    "            & (x[\"IsRefresh\"] == 0)\n",
    "            & (x[\"DontCountHits\"] == 0)\n",
    "            & (x[\"URLHash\"] == 2868770270353813622)\n",
    "        ]\n",
    "        .groupby([\"WindowClientWidth\", \"WindowClientHeight\"])\n",
    "        .size()\n",
    "        .nlargest(10)\n",
    "        .reset_index(name=\"PageViews\")\n",
    "        .iloc[10000:10010],\n",
    "        lambda x: x.filter(\n",
    "            (pl.col(\"CounterID\") == 62)\n",
    "            & (pl.col(\"EventDate\") >= pl.datetime(2013, 7, 1))\n",
    "            & (pl.col(\"EventDate\") <= pl.datetime(2013, 7, 31))\n",
    "            & (pl.col(\"IsRefresh\") == 0)\n",
    "            & (pl.col(\"DontCountHits\") == 0)\n",
    "            & (pl.col(\"URLHash\") == 2868770270353813622)\n",
    "        )\n",
    "        .group_by([\"WindowClientWidth\", \"WindowClientHeight\"])\n",
    "        .agg(pl.len().alias(\"PageViews\"))\n",
    "        .sort(\"PageViews\", descending=True)\n",
    "        .slice(10000, 10),\n",
    "    ),\n",
    "    (\n",
    "        \"Q42\",\n",
    "        \"SELECT DATE_TRUNC('minute', EventTime) AS M, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-14' AND EventDate <= '2013-07-15' AND IsRefresh = 0 AND DontCountHits = 0 GROUP BY DATE_TRUNC('minute', EventTime) ORDER BY DATE_TRUNC('minute', EventTime) LIMIT 10 OFFSET 1000;\",\n",
    "        lambda x: x[\n",
    "            (x[\"CounterID\"] == 62)\n",
    "            & (x[\"EventDate\"] >= \"2013-07-14\")\n",
    "            & (x[\"EventDate\"] <= \"2013-07-15\")\n",
    "            & (x[\"IsRefresh\"] == 0)\n",
    "            & (x[\"DontCountHits\"] == 0)\n",
    "        ]\n",
    "        .groupby(pd.Grouper(key=\"EventTime\", freq=\"T\"))\n",
    "        .size()\n",
    "        .reset_index(name=\"PageViews\")\n",
    "        .iloc[1000:1010],\n",
    "        lambda x: None,\n",
    "        # Crash with:\n",
    "        #   thread '<unnamed>' panicked at crates/polars-time/src/windows/duration.rs:215:21:\n",
    "        #   expected leading integer in the duration string, found m\n",
    "        # lambda x: x.filter(\n",
    "        #     (pl.col(\"CounterID\") == 62)\n",
    "        #     & (pl.col(\"EventDate\") >= pl.datetime(2013, 7, 14))\n",
    "        #     & (pl.col(\"EventDate\") <= pl.datetime(2013, 7, 15))\n",
    "        #     & (pl.col(\"IsRefresh\") == 0)\n",
    "        #     & (pl.col(\"DontCountHits\") == 0)\n",
    "        # )\n",
    "        # .group_by(pl.col(\"EventTime\").dt.truncate(\"minute\"))\n",
    "        # .agg(pl.len().alias(\"PageViews\"))\n",
    "        # .slice(1000, 10),\n",
    "    ),\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "counter = 0\n",
    "\n",
    "\n",
    "def runDuckDB(con, sql):\n",
    "    used_time = None\n",
    "    try:\n",
    "        t = time.time()\n",
    "        ret = con.execute(sql).fetch_df()\n",
    "        used_time = time.time() - t\n",
    "        print(\"DuckDB time:\", used_time)\n",
    "        print(\"DuckDB return:\\n\", ret)\n",
    "    except Exception as e:\n",
    "        print(\"DuckDB error:\", e)\n",
    "    return used_time\n",
    "\n",
    "def runChDB(sess, sql):\n",
    "    used_time = None\n",
    "    # replace 'hits' with 'Python(df_reader)'\n",
    "    sql = sql.replace(\"hits\", \"Python(hits)\")\n",
    "    # sql = sql.replace(\"hits\", \"__hits__\")\n",
    "    sql = sql.replace(\"STRLEN\", \"length\")\n",
    "    if \"SELECT DATE_TRUNC('minute', EventTime) AS M\" in sql:\n",
    "        sql = \"SELECT DATE_TRUNC('minute', EventTime) AS M, COUNT(*) AS PageViews FROM Python(hits) WHERE CounterID = 62  AND EventDate >= '2013-07-14'  AND EventDate <= '2013-07-15' AND IsRefresh = 0 AND DontCountHits = 0 GROUP BY DATE_TRUNC('minute', EventTime) ORDER BY DATE_TRUNC('minute', EventTime) LIMIT 10 OFFSET 1000\"\n",
    "    try:\n",
    "        t = time.time()\n",
    "        ret = chdb.query(sql, \"CSV\")\n",
    "        used_time = time.time() - t\n",
    "        print(\"chDB time:\", used_time)\n",
    "        print(\"chDB return:\\n\", ret)\n",
    "    except Exception as e:\n",
    "        print(\"chDB error:\", e)\n",
    "    return used_time\n",
    "\n",
    "def runPandas(f):\n",
    "    t = time.time()\n",
    "    ret = f(hits)\n",
    "    used_time = time.time() - t\n",
    "    print(\"Pandas time:\", used_time)\n",
    "    print(\"Pandas return:\\n\", ret)\n",
    "    return used_time\n",
    "\n",
    "def runPolars(f):\n",
    "    used_time = None\n",
    "    try:\n",
    "        t = time.time()\n",
    "        ret = f(pl_df)\n",
    "        used_time = time.time() - t\n",
    "        print(\"Polars time:\", used_time)\n",
    "        print(\"Polars return:\\n\", ret)\n",
    "        if ret is None:\n",
    "            return None\n",
    "    except Exception as e:\n",
    "        print(\"Polars error:\", e)\n",
    "    return used_time\n",
    "\n",
    "def bench(q, N=1):\n",
    "    global counter\n",
    "    con = duckdb.connect()\n",
    "    # df_reader = myReader(hits)\n",
    "    duckdb_time = []\n",
    "    chdb_time = []\n",
    "    pandas_time = []\n",
    "    polars_time = []\n",
    "    sql = q[1]\n",
    "    print(q[0], sql)\n",
    "    # pandas is too slow, only run once\n",
    "    pandas_time.append(runPandas(q[2]))\n",
    "    for i in range(N):\n",
    "        duckdb_time.append(runDuckDB(con, sql))\n",
    "        chdb_time.append(runChDB(None, sql))\n",
    "        polars_time.append(runPolars(q[3]))\n",
    "    counter += 1\n",
    "    pandas_time = pandas_time * N\n",
    "    return duckdb_time, chdb_time, pandas_time, polars_time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Q0 SELECT COUNT(*) FROM hits;\n",
      "Pandas time: 8.789468765258789\n",
      "Pandas return:\n",
      " WatchID        10000000\n",
      "JavaEnable     10000000\n",
      "Title          10000000\n",
      "GoodEvent      10000000\n",
      "EventTime      10000000\n",
      "                 ...   \n",
      "FromTag        10000000\n",
      "HasGCLID       10000000\n",
      "RefererHash    10000000\n",
      "URLHash        10000000\n",
      "CLID           10000000\n",
      "Length: 105, dtype: int64\n",
      "DuckDB time: 0.03433990478515625\n",
      "DuckDB return:\n",
      "    count_star()\n",
      "0      10000000\n",
      "chDB time: 0.06516456604003906\n",
      "chDB return:\n",
      " 10000000\n",
      "\n",
      "Polars time: 1.6450881958007812e-05\n",
      "Polars return:\n",
      " 10000000\n",
      "Q1 SELECT COUNT(*) FROM hits WHERE AdvEngineID <> 0;\n",
      "Pandas time: 0.16229581832885742\n",
      "Pandas return:\n",
      " WatchID        99649\n",
      "JavaEnable     99649\n",
      "Title          99649\n",
      "GoodEvent      99649\n",
      "EventTime      99649\n",
      "               ...  \n",
      "FromTag        99649\n",
      "HasGCLID       99649\n",
      "RefererHash    99649\n",
      "URLHash        99649\n",
      "CLID           99649\n",
      "Length: 105, dtype: int64\n",
      "DuckDB time: 0.026508569717407227\n",
      "DuckDB return:\n",
      "    count_star()\n",
      "0         99649\n",
      "chDB time: 0.027498722076416016\n",
      "chDB return:\n",
      " 99649\n",
      "\n",
      "Polars time: 0.02317357063293457\n",
      "Polars return:\n",
      " 99649\n",
      "Q2 SELECT SUM(AdvEngineID), COUNT(*), AVG(ResolutionWidth) FROM hits;\n",
      "Pandas time: 0.007686138153076172\n",
      "Pandas return:\n",
      " (1635226, 10000000, 1507.7792377)\n",
      "DuckDB time: 0.02513861656188965\n",
      "DuckDB return:\n",
      "    sum(AdvEngineID)  count_star()  avg(ResolutionWidth)\n",
      "0         1635226.0      10000000           1507.779238\n",
      "chDB time: 0.02389240264892578\n",
      "chDB return:\n",
      " 1635226,10000000,1507.7792377\n",
      "\n",
      "Polars time: 0.03767538070678711\n",
      "Polars return:\n",
      " (1635226, 10000000, 1507.7792377)\n",
      "Q3 SELECT AVG(UserID) FROM hits;\n",
      "Pandas time: 0.007529735565185547\n",
      "Pandas return:\n",
      " 2.50007340441956e+18\n",
      "DuckDB time: 0.021852970123291016\n",
      "DuckDB return:\n",
      "     avg(UserID)\n",
      "0  2.500073e+18\n",
      "chDB time: 0.026594877243041992\n",
      "chDB return:\n",
      " -907169442272.5032\n",
      "\n",
      "Polars time: 0.004158496856689453\n",
      "Polars return:\n",
      " 2.5000734044195615e+18\n",
      "Q4 SELECT COUNT(DISTINCT UserID) FROM hits;\n",
      "Pandas time: 0.21137714385986328\n",
      "Pandas return:\n",
      " 2161466\n",
      "DuckDB time: 0.07819533348083496\n",
      "DuckDB return:\n",
      "    count(DISTINCT UserID)\n",
      "0                 2161466\n",
      "chDB time: 0.18276023864746094\n",
      "chDB return:\n",
      " 2161466\n",
      "\n",
      "Polars time: 0.13331985473632812\n",
      "Polars return:\n",
      " 2161466\n",
      "Q5 SELECT COUNT(DISTINCT SearchPhrase) FROM hits;\n",
      "Pandas time: 0.6686234474182129\n",
      "Pandas return:\n",
      " 849107\n",
      "DuckDB time: 0.08364367485046387\n",
      "DuckDB return:\n",
      "    count(DISTINCT SearchPhrase)\n",
      "0                        849107\n",
      "chDB time: 0.1492304801940918\n",
      "chDB return:\n",
      " 849107\n",
      "\n",
      "Polars time: 0.3041989803314209\n",
      "Polars return:\n",
      " 849107\n",
      "Q6 SELECT MIN(EventDate), MAX(EventDate) FROM hits;\n",
      "Pandas time: 0.02013540267944336\n",
      "Pandas return:\n",
      " (Timestamp('2013-07-02 00:00:00'), Timestamp('2013-07-31 00:00:00'))\n",
      "DuckDB time: 0.024533987045288086\n",
      "DuckDB return:\n",
      "   min(EventDate) max(EventDate)\n",
      "0     2013-07-02     2013-07-31\n",
      "chDB time: 0.025769948959350586\n",
      "chDB return:\n",
      " \"2013-07-02 08:00:00.000000000\",\"2013-07-31 08:00:00.000000000\"\n",
      "\n",
      "Polars time: 0.00613856315612793\n",
      "Polars return:\n",
      " (datetime.datetime(2013, 7, 2, 0, 0), datetime.datetime(2013, 7, 31, 0, 0))\n",
      "Q7 SELECT AdvEngineID, COUNT(*) FROM hits WHERE AdvEngineID <> 0 GROUP BY AdvEngineID ORDER BY COUNT(*) DESC;\n",
      "Pandas time: 0.07054853439331055\n",
      "Pandas return:\n",
      " AdvEngineID\n",
      "2     46435\n",
      "27    39607\n",
      "45     5764\n",
      "13     4216\n",
      "44     3067\n",
      "52      330\n",
      "3        79\n",
      "50       62\n",
      "28       59\n",
      "61       15\n",
      "53       14\n",
      "25        1\n",
      "dtype: int64\n",
      "DuckDB time: 0.046100616455078125\n",
      "DuckDB return:\n",
      "     AdvEngineID  count_star()\n",
      "0             2         46435\n",
      "1            27         39607\n",
      "2            45          5764\n",
      "3            13          4216\n",
      "4            44          3067\n",
      "5            52           330\n",
      "6             3            79\n",
      "7            50            62\n",
      "8            28            59\n",
      "9            61            15\n",
      "10           53            14\n",
      "11           25             1\n",
      "chDB time: 0.054378509521484375\n",
      "chDB return:\n",
      " 2,46435\n",
      "27,39607\n",
      "45,5764\n",
      "13,4216\n",
      "44,3067\n",
      "52,330\n",
      "3,79\n",
      "50,62\n",
      "28,59\n",
      "61,15\n",
      "53,14\n",
      "25,1\n",
      "\n",
      "Polars time: 0.027820348739624023\n",
      "Polars return:\n",
      " shape: (12, 2)\n",
      "┌─────────────┬───────┐\n",
      "│ AdvEngineID ┆ count │\n",
      "│ ---         ┆ ---   │\n",
      "│ i16         ┆ u32   │\n",
      "╞═════════════╪═══════╡\n",
      "│ 2           ┆ 46435 │\n",
      "│ 27          ┆ 39607 │\n",
      "│ 45          ┆ 5764  │\n",
      "│ 13          ┆ 4216  │\n",
      "│ 44          ┆ 3067  │\n",
      "│ …           ┆ …     │\n",
      "│ 50          ┆ 62    │\n",
      "│ 28          ┆ 59    │\n",
      "│ 61          ┆ 15    │\n",
      "│ 53          ┆ 14    │\n",
      "│ 25          ┆ 1     │\n",
      "└─────────────┴───────┘\n",
      "Q8 SELECT RegionID, COUNT(DISTINCT UserID) AS u FROM hits GROUP BY RegionID ORDER BY u DESC LIMIT 10;\n",
      "Pandas time: 0.5789997577667236\n",
      "Pandas return:\n",
      " RegionID\n",
      "229    356130\n",
      "2      150316\n",
      "208    100038\n",
      "169     69299\n",
      "107     37571\n",
      "34      35246\n",
      "184     34285\n",
      "55      33522\n",
      "158     31849\n",
      "42      31432\n",
      "Name: UserID, dtype: int64\n",
      "DuckDB time: 0.09088969230651855\n",
      "DuckDB return:\n",
      "    RegionID       u\n",
      "0       229  356130\n",
      "1         2  150316\n",
      "2       208  100038\n",
      "3       169   69299\n",
      "4       107   37571\n",
      "5        34   35246\n",
      "6       184   34285\n",
      "7        55   33522\n",
      "8       158   31849\n",
      "9        42   31432\n",
      "chDB time: 0.08289217948913574\n",
      "chDB return:\n",
      " 229,356130\n",
      "2,150316\n",
      "208,100038\n",
      "169,69299\n",
      "107,37571\n",
      "34,35246\n",
      "184,34285\n",
      "55,33522\n",
      "158,31849\n",
      "42,31432\n",
      "\n",
      "Polars time: 0.2607238292694092\n",
      "Polars return:\n",
      " shape: (10, 2)\n",
      "┌──────────┬────────┐\n",
      "│ RegionID ┆ UserID │\n",
      "│ ---      ┆ ---    │\n",
      "│ i32      ┆ u32    │\n",
      "╞══════════╪════════╡\n",
      "│ 229      ┆ 356130 │\n",
      "│ 2        ┆ 150316 │\n",
      "│ 208      ┆ 100038 │\n",
      "│ 169      ┆ 69299  │\n",
      "│ 107      ┆ 37571  │\n",
      "│ 34       ┆ 35246  │\n",
      "│ 184      ┆ 34285  │\n",
      "│ 55       ┆ 33522  │\n",
      "│ 158      ┆ 31849  │\n",
      "│ 42       ┆ 31432  │\n",
      "└──────────┴────────┘\n",
      "Q9 SELECT RegionID, SUM(AdvEngineID), COUNT(*) AS c, AVG(ResolutionWidth), COUNT(DISTINCT UserID) FROM hits GROUP BY RegionID ORDER BY c DESC LIMIT 10;\n",
      "Pandas time: 0.6821517944335938\n",
      "Pandas return:\n",
      "           AdvEngineID  ResolutionWidth  UserID\n",
      "RegionID                                      \n",
      "229            391301      1511.768654  356130\n",
      "2              101985      1426.560820  150316\n",
      "208             69554      1291.526935  100038\n",
      "34              32232      1560.577018   35246\n",
      "42              27753      1593.974549   31432\n",
      "55              26257      1346.594102   33522\n",
      "1               25468      1571.634042   28590\n",
      "107             25014      1415.724206   37571\n",
      "169             23595      1460.090695   69299\n",
      "51              22510      1584.785671   25803\n",
      "DuckDB time: 0.12663817405700684\n",
      "DuckDB return:\n",
      "    RegionID  sum(AdvEngineID)        c  avg(ResolutionWidth)  \\\n",
      "0       229          391301.0  1819609           1511.768654   \n",
      "1         2          101985.0   732566           1426.560820   \n",
      "2       208           69554.0   425791           1291.526935   \n",
      "3       169           23595.0   409150           1460.090695   \n",
      "4       184           12140.0   182579           1489.535817   \n",
      "5        32           20741.0   172420           1563.620601   \n",
      "6        42           27753.0   158223           1593.974549   \n",
      "7       107           25014.0   149231           1415.724206   \n",
      "8        34           32232.0   141992           1560.577018   \n",
      "9        55           26257.0   138998           1346.594102   \n",
      "\n",
      "   count(DISTINCT UserID)  \n",
      "0                  356130  \n",
      "1                  150316  \n",
      "2                  100038  \n",
      "3                   69299  \n",
      "4                   34285  \n",
      "5                   27290  \n",
      "6                   31432  \n",
      "7                   37571  \n",
      "8                   35246  \n",
      "9                   33522  \n",
      "chDB time: 0.09233450889587402\n",
      "chDB return:\n",
      " 229,391301,1819609,1511.7686535953603,356130\n",
      "2,101985,732566,1426.560820458498,150316\n",
      "208,69554,425791,1291.5269345758834,100038\n",
      "169,23595,409150,1460.0906953440058,69299\n",
      "184,12140,182579,1489.535817372206,34285\n",
      "32,20741,172420,1563.620600858369,27290\n",
      "42,27753,158223,1593.9745485801684,31432\n",
      "107,25014,149231,1415.7242060965884,37571\n",
      "34,32232,141992,1560.5770184235732,35246\n",
      "55,26257,138998,1346.594102073411,33522\n",
      "\n",
      "Polars time: 0.24764204025268555\n",
      "Polars return:\n",
      " shape: (10, 4)\n",
      "┌──────────┬─────────────────┬──────────────────────┬────────────────┐\n",
      "│ RegionID ┆ AdvEngineID_sum ┆ ResolutionWidth_mean ┆ UserID_nunique │\n",
      "│ ---      ┆ ---             ┆ ---                  ┆ ---            │\n",
      "│ i32      ┆ i64             ┆ f64                  ┆ u32            │\n",
      "╞══════════╪═════════════════╪══════════════════════╪════════════════╡\n",
      "│ 229      ┆ 391301          ┆ 1511.768654          ┆ 356130         │\n",
      "│ 2        ┆ 101985          ┆ 1426.56082           ┆ 150316         │\n",
      "│ 208      ┆ 69554           ┆ 1291.526935          ┆ 100038         │\n",
      "│ 34       ┆ 32232           ┆ 1560.577018          ┆ 35246          │\n",
      "│ 42       ┆ 27753           ┆ 1593.974549          ┆ 31432          │\n",
      "│ 55       ┆ 26257           ┆ 1346.594102          ┆ 33522          │\n",
      "│ 1        ┆ 25468           ┆ 1571.634042          ┆ 28590          │\n",
      "│ 107      ┆ 25014           ┆ 1415.724206          ┆ 37571          │\n",
      "│ 169      ┆ 23595           ┆ 1460.090695          ┆ 69299          │\n",
      "│ 51       ┆ 22510           ┆ 1584.785671          ┆ 25803          │\n",
      "└──────────┴─────────────────┴──────────────────────┴────────────────┘\n",
      "Q10 SELECT MobilePhoneModel, COUNT(DISTINCT UserID) AS u FROM hits WHERE MobilePhoneModel <> '' GROUP BY MobilePhoneModel ORDER BY u DESC LIMIT 10;\n",
      "Pandas time: 0.839637279510498\n",
      "Pandas return:\n",
      " MobilePhoneModel\n",
      "iPad               127994\n",
      "iPhone               5736\n",
      "A500                 2177\n",
      "N8-00                 680\n",
      "iPho                  364\n",
      "ONE TOUCH 6030A       315\n",
      "GT-P7300B             239\n",
      "3110000               217\n",
      "GT-I9500              198\n",
      "eagle75               181\n",
      "Name: UserID, dtype: int64\n",
      "DuckDB time: 0.052741050720214844\n",
      "DuckDB return:\n",
      "   MobilePhoneModel       u\n",
      "0             iPad  127994\n",
      "1           iPhone    5736\n",
      "2             A500    2177\n",
      "3            N8-00     680\n",
      "4             iPho     364\n",
      "5  ONE TOUCH 6030A     315\n",
      "6        GT-P7300B     239\n",
      "7          3110000     217\n",
      "8         GT-I9500     198\n",
      "9          eagle75     181\n",
      "chDB time: 0.09442925453186035\n",
      "chDB return:\n",
      " \"iPad\",127994\n",
      "\"iPhone\",5736\n",
      "\"A500\",2177\n",
      "\"N8-00\",680\n",
      "\"iPho\",364\n",
      "\"ONE TOUCH 6030A\",315\n",
      "\"GT-P7300B\",239\n",
      "\"3110000\",217\n",
      "\"GT-I9500\",198\n",
      "\"eagle75\",181\n",
      "\n",
      "Polars time: 0.12893366813659668\n",
      "Polars return:\n",
      " shape: (10, 2)\n",
      "┌──────────────────┬────────┐\n",
      "│ MobilePhoneModel ┆ UserID │\n",
      "│ ---              ┆ ---    │\n",
      "│ str              ┆ u32    │\n",
      "╞══════════════════╪════════╡\n",
      "│ iPad             ┆ 127994 │\n",
      "│ iPhone           ┆ 5736   │\n",
      "│ A500             ┆ 2177   │\n",
      "│ N8-00            ┆ 680    │\n",
      "│ iPho             ┆ 364    │\n",
      "│ ONE TOUCH 6030A  ┆ 315    │\n",
      "│ GT-P7300B        ┆ 239    │\n",
      "│ 3110000          ┆ 217    │\n",
      "│ GT-I9500         ┆ 198    │\n",
      "│ eagle75          ┆ 181    │\n",
      "└──────────────────┴────────┘\n",
      "Q11 SELECT MobilePhone, MobilePhoneModel, COUNT(DISTINCT UserID) AS u FROM hits WHERE MobilePhoneModel <> '' GROUP BY MobilePhone, MobilePhoneModel ORDER BY u DESC LIMIT 10;\n",
      "Pandas time: 0.8696815967559814\n",
      "Pandas return:\n",
      " MobilePhone  MobilePhoneModel\n",
      "1            iPad                108339\n",
      "5            iPad                  6054\n",
      "6            iPad                  3638\n",
      "7            iPad                  3356\n",
      "118          A500                  2167\n",
      "6            iPhone                1844\n",
      "26           iPhone                1584\n",
      "10           iPad                  1370\n",
      "32           iPad                  1196\n",
      "13           iPad                  1163\n",
      "Name: UserID, dtype: int64\n",
      "DuckDB time: 0.0588836669921875\n",
      "DuckDB return:\n",
      "    MobilePhone MobilePhoneModel       u\n",
      "0            1             iPad  108339\n",
      "1            5             iPad    6054\n",
      "2            6             iPad    3638\n",
      "3            7             iPad    3356\n",
      "4          118             A500    2167\n",
      "5            6           iPhone    1844\n",
      "6           26           iPhone    1584\n",
      "7           10             iPad    1370\n",
      "8           32             iPad    1196\n",
      "9           13             iPad    1163\n",
      "chDB time: 0.05849885940551758\n",
      "chDB return:\n",
      " 1,\"iPad\",108339\n",
      "5,\"iPad\",6054\n",
      "6,\"iPad\",3638\n",
      "7,\"iPad\",3356\n",
      "118,\"A500\",2167\n",
      "6,\"iPhone\",1844\n",
      "26,\"iPhone\",1584\n",
      "10,\"iPad\",1370\n",
      "32,\"iPad\",1196\n",
      "13,\"iPad\",1163\n",
      "\n",
      "Polars time: 0.1208345890045166\n",
      "Polars return:\n",
      " shape: (10, 3)\n",
      "┌─────────────┬──────────────────┬────────┐\n",
      "│ MobilePhone ┆ MobilePhoneModel ┆ UserID │\n",
      "│ ---         ┆ ---              ┆ ---    │\n",
      "│ i16         ┆ str              ┆ u32    │\n",
      "╞═════════════╪══════════════════╪════════╡\n",
      "│ 1           ┆ iPad             ┆ 108339 │\n",
      "│ 5           ┆ iPad             ┆ 6054   │\n",
      "│ 6           ┆ iPad             ┆ 3638   │\n",
      "│ 7           ┆ iPad             ┆ 3356   │\n",
      "│ 118         ┆ A500             ┆ 2167   │\n",
      "│ 6           ┆ iPhone           ┆ 1844   │\n",
      "│ 26          ┆ iPhone           ┆ 1584   │\n",
      "│ 10          ┆ iPad             ┆ 1370   │\n",
      "│ 32          ┆ iPad             ┆ 1196   │\n",
      "│ 13          ┆ iPad             ┆ 1163   │\n",
      "└─────────────┴──────────────────┴────────┘\n",
      "Q12 SELECT SearchPhrase, COUNT(*) AS c FROM hits WHERE SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY c DESC LIMIT 10;\n",
      "Pandas time: 2.7713074684143066\n",
      "Pandas return:\n",
      " SearchPhrase\n",
      "албатрутдин                  6310\n",
      "какой областиков             3120\n",
      "смотреть онлайн              2678\n",
      "какой областиницы цена       2497\n",
      "смотреть онлайн бесплатно    2485\n",
      "galaxy table                 1996\n",
      "смотреть                     1944\n",
      "ведомосквы вместу            1559\n",
      "экзоидные                    1432\n",
      "карелки                      1280\n",
      "dtype: int64\n",
      "DuckDB time: 0.09914731979370117\n",
      "DuckDB return:\n",
      "                 SearchPhrase     c\n",
      "0                албатрутдин  6310\n",
      "1           какой областиков  3120\n",
      "2            смотреть онлайн  2678\n",
      "3     какой областиницы цена  2497\n",
      "4  смотреть онлайн бесплатно  2485\n",
      "5               galaxy table  1996\n",
      "6                   смотреть  1944\n",
      "7          ведомосквы вместу  1559\n",
      "8                  экзоидные  1432\n",
      "9                    карелки  1280\n",
      "chDB time: 0.12346029281616211\n",
      "chDB return:\n",
      " \"албатрутдин\",6310\n",
      "\"какой областиков\",3120\n",
      "\"смотреть онлайн\",2678\n",
      "\"какой областиницы цена\",2497\n",
      "\"смотреть онлайн бесплатно\",2485\n",
      "\"galaxy table\",1996\n",
      "\"смотреть\",1944\n",
      "\"ведомосквы вместу\",1559\n",
      "\"экзоидные\",1432\n",
      "\"карелки\",1280\n",
      "\n",
      "Polars time: 0.19979619979858398\n",
      "Polars return:\n",
      " shape: (10, 2)\n",
      "┌───────────────────────────┬───────┐\n",
      "│ SearchPhrase              ┆ count │\n",
      "│ ---                       ┆ ---   │\n",
      "│ str                       ┆ u32   │\n",
      "╞═══════════════════════════╪═══════╡\n",
      "│ албатрутдин               ┆ 6310  │\n",
      "│ какой областиков          ┆ 3120  │\n",
      "│ смотреть онлайн           ┆ 2678  │\n",
      "│ какой областиницы цена    ┆ 2497  │\n",
      "│ смотреть онлайн бесплатно ┆ 2485  │\n",
      "│ galaxy table              ┆ 1996  │\n",
      "│ смотреть                  ┆ 1944  │\n",
      "│ ведомосквы вместу         ┆ 1559  │\n",
      "│ экзоидные                 ┆ 1432  │\n",
      "│ карелки                   ┆ 1280  │\n",
      "└───────────────────────────┴───────┘\n",
      "Q13 SELECT SearchPhrase, COUNT(DISTINCT UserID) AS u FROM hits WHERE SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY u DESC LIMIT 10;\n",
      "Pandas time: 2.760340929031372\n",
      "Pandas return:\n",
      " SearchPhrase\n",
      "албатрутдин                        3373\n",
      "какой областиков                   2360\n",
      "смотреть онлайн                    2199\n",
      "смотреть онлайн бесплатно          2066\n",
      "какой областиницы цена             1860\n",
      "смотреть                           1498\n",
      "экзоидные                          1256\n",
      "тайны избавлению акручить           960\n",
      "какой области за улыбки бмв е34     936\n",
      "galaxy table                        868\n",
      "Name: UserID, dtype: int64\n",
      "DuckDB time: 0.1588895320892334\n",
      "DuckDB return:\n",
      "                       SearchPhrase     u\n",
      "0                      албатрутдин  3373\n",
      "1                 какой областиков  2360\n",
      "2                  смотреть онлайн  2199\n",
      "3        смотреть онлайн бесплатно  2066\n",
      "4           какой областиницы цена  1860\n",
      "5                         смотреть  1498\n",
      "6                        экзоидные  1256\n",
      "7        тайны избавлению акручить   960\n",
      "8  какой области за улыбки бмв е34   936\n",
      "9                     galaxy table   868\n",
      "chDB time: 0.11397171020507812\n",
      "chDB return:\n",
      " \"албатрутдин\",3373\n",
      "\"какой областиков\",2360\n",
      "\"смотреть онлайн\",2199\n",
      "\"смотреть онлайн бесплатно\",2066\n",
      "\"какой областиницы цена\",1860\n",
      "\"смотреть\",1498\n",
      "\"экзоидные\",1256\n",
      "\"тайны избавлению акручить\",960\n",
      "\"какой области за улыбки бмв е34\",936\n",
      "\"galaxy table\",868\n",
      "\n",
      "Polars time: 22.400670289993286\n",
      "Polars return:\n",
      " shape: (10, 2)\n",
      "┌─────────────────────────────────┬────────┐\n",
      "│ SearchPhrase                    ┆ UserID │\n",
      "│ ---                             ┆ ---    │\n",
      "│ str                             ┆ u32    │\n",
      "╞═════════════════════════════════╪════════╡\n",
      "│ албатрутдин                     ┆ 3373   │\n",
      "│ какой областиков                ┆ 2360   │\n",
      "│ смотреть онлайн                 ┆ 2199   │\n",
      "│ смотреть онлайн бесплатно       ┆ 2066   │\n",
      "│ какой областиницы цена          ┆ 1860   │\n",
      "│ смотреть                        ┆ 1498   │\n",
      "│ экзоидные                       ┆ 1256   │\n",
      "│ тайны избавлению акручить       ┆ 960    │\n",
      "│ какой области за улыбки бмв е3… ┆ 936    │\n",
      "│ galaxy table                    ┆ 868    │\n",
      "└─────────────────────────────────┴────────┘\n",
      "Q14 SELECT SearchEngineID, SearchPhrase, COUNT(*) AS c FROM hits WHERE SearchPhrase <> '' GROUP BY SearchEngineID, SearchPhrase ORDER BY c DESC LIMIT 10;\n",
      "Pandas time: 8.411752223968506\n",
      "Pandas return:\n",
      " SearchEngineID  SearchPhrase                      \n",
      "3               албатрутдин                           3016\n",
      "2               албатрутдин                           2585\n",
      "                какой областиницы цена                2432\n",
      "                смотреть онлайн                       1964\n",
      "                смотреть онлайн бесплатно             1765\n",
      "                какой областиков                      1599\n",
      "                смотреть                              1291\n",
      "                тайны избавлению акручить             1273\n",
      "                экзоидные                             1187\n",
      "                тихоокеанский списание пределирова    1079\n",
      "dtype: int64\n",
      "DuckDB time: 0.10474276542663574\n",
      "DuckDB return:\n",
      "    SearchEngineID                        SearchPhrase     c\n",
      "0               3                         албатрутдин  3016\n",
      "1               2                         албатрутдин  2585\n",
      "2               2              какой областиницы цена  2432\n",
      "3               2                     смотреть онлайн  1964\n",
      "4               2           смотреть онлайн бесплатно  1765\n",
      "5               2                    какой областиков  1599\n",
      "6               2                            смотреть  1291\n",
      "7               2           тайны избавлению акручить  1273\n",
      "8               2                           экзоидные  1187\n",
      "9               2  тихоокеанский списание пределирова  1079\n",
      "chDB time: 0.10899591445922852\n",
      "chDB return:\n",
      " 3,\"албатрутдин\",3016\n",
      "2,\"албатрутдин\",2585\n",
      "2,\"какой областиницы цена\",2432\n",
      "2,\"смотреть онлайн\",1964\n",
      "2,\"смотреть онлайн бесплатно\",1765\n",
      "2,\"какой областиков\",1599\n",
      "2,\"смотреть\",1291\n",
      "2,\"тайны избавлению акручить\",1273\n",
      "2,\"экзоидные\",1187\n",
      "2,\"тихоокеанский списание пределирова\",1079\n",
      "\n",
      "Polars time: 0.18914175033569336\n",
      "Polars return:\n",
      " shape: (10, 3)\n",
      "┌────────────────┬─────────────────────────────────┬───────┐\n",
      "│ SearchEngineID ┆ SearchPhrase                    ┆ count │\n",
      "│ ---            ┆ ---                             ┆ ---   │\n",
      "│ i16            ┆ str                             ┆ u32   │\n",
      "╞════════════════╪═════════════════════════════════╪═══════╡\n",
      "│ 3              ┆ албатрутдин                     ┆ 3016  │\n",
      "│ 2              ┆ албатрутдин                     ┆ 2585  │\n",
      "│ 2              ┆ какой областиницы цена          ┆ 2432  │\n",
      "│ 2              ┆ смотреть онлайн                 ┆ 1964  │\n",
      "│ 2              ┆ смотреть онлайн бесплатно       ┆ 1765  │\n",
      "│ 2              ┆ какой областиков                ┆ 1599  │\n",
      "│ 2              ┆ смотреть                        ┆ 1291  │\n",
      "│ 2              ┆ тайны избавлению акручить       ┆ 1273  │\n",
      "│ 2              ┆ экзоидные                       ┆ 1187  │\n",
      "│ 2              ┆ тихоокеанский списание предели… ┆ 1079  │\n",
      "└────────────────┴─────────────────────────────────┴───────┘\n",
      "Q15 SELECT UserID, COUNT(*) FROM hits GROUP BY UserID ORDER BY COUNT(*) DESC LIMIT 10;\n",
      "Pandas time: 0.7016208171844482\n",
      "Pandas return:\n",
      " UserID\n",
      "1313338681122956954    15792\n",
      "1907779576417363396     6229\n",
      "5730251990344211405     6019\n",
      "7280399273658728997     6015\n",
      "835157184735512989      5211\n",
      "823824530034798601      2897\n",
      "938290163257834024      2685\n",
      "4931847376428061501     2537\n",
      "6949028786848070043     2496\n",
      "2763860660987168393     2179\n",
      "dtype: int64\n",
      "DuckDB time: 0.08089947700500488\n",
      "DuckDB return:\n",
      "                 UserID  count_star()\n",
      "0  1313338681122956954         15792\n",
      "1  1907779576417363396          6229\n",
      "2  5730251990344211405          6019\n",
      "3  7280399273658728997          6015\n",
      "4   835157184735512989          5211\n",
      "5   823824530034798601          2897\n",
      "6   938290163257834024          2685\n",
      "7  4931847376428061501          2537\n",
      "8  6949028786848070043          2496\n",
      "9  2763860660987168393          2179\n",
      "chDB time: 0.08938097953796387\n",
      "chDB return:\n",
      " 1313338681122956954,15792\n",
      "1907779576417363396,6229\n",
      "5730251990344211405,6019\n",
      "7280399273658728997,6015\n",
      "835157184735512989,5211\n",
      "823824530034798601,2897\n",
      "938290163257834024,2685\n",
      "4931847376428061501,2537\n",
      "6949028786848070043,2496\n",
      "2763860660987168393,2179\n",
      "\n",
      "Polars time: 0.12315940856933594\n",
      "Polars return:\n",
      " shape: (10, 2)\n",
      "┌─────────────────────┬───────┐\n",
      "│ UserID              ┆ count │\n",
      "│ ---                 ┆ ---   │\n",
      "│ i64                 ┆ u32   │\n",
      "╞═════════════════════╪═══════╡\n",
      "│ 1313338681122956954 ┆ 15792 │\n",
      "│ 1907779576417363396 ┆ 6229  │\n",
      "│ 5730251990344211405 ┆ 6019  │\n",
      "│ 7280399273658728997 ┆ 6015  │\n",
      "│ 835157184735512989  ┆ 5211  │\n",
      "│ 823824530034798601  ┆ 2897  │\n",
      "│ 938290163257834024  ┆ 2685  │\n",
      "│ 4931847376428061501 ┆ 2537  │\n",
      "│ 6949028786848070043 ┆ 2496  │\n",
      "│ 2763860660987168393 ┆ 2179  │\n",
      "└─────────────────────┴───────┘\n",
      "Q16 SELECT UserID, SearchPhrase, COUNT(*) FROM hits GROUP BY UserID, SearchPhrase ORDER BY COUNT(*) DESC LIMIT 10;\n",
      "Pandas time: 25.73132586479187\n",
      "Pandas return:\n",
      " UserID               SearchPhrase\n",
      "1313338681122956954                  15792\n",
      "1907779576417363396                   6229\n",
      "5730251990344211405                   6019\n",
      "7280399273658728997                   6015\n",
      "835157184735512989                    5209\n",
      "823824530034798601                    2897\n",
      "938290163257834024                    2684\n",
      "4931847376428061501                   2537\n",
      "6949028786848070043                   2496\n",
      "2763860660987168393                   2179\n",
      "dtype: int64\n",
      "DuckDB time: 0.14031195640563965\n",
      "DuckDB return:\n",
      "                 UserID SearchPhrase  count_star()\n",
      "0  1313338681122956954                      15792\n",
      "1  1907779576417363396                       6229\n",
      "2  5730251990344211405                       6019\n",
      "3  7280399273658728997                       6015\n",
      "4   835157184735512989                       5209\n",
      "5   823824530034798601                       2897\n",
      "6   938290163257834024                       2684\n",
      "7  4931847376428061501                       2537\n",
      "8  6949028786848070043                       2496\n",
      "9  2763860660987168393                       2179\n",
      "chDB time: 0.15292119979858398\n",
      "chDB return:\n",
      " 1313338681122956954,\"\",15792\n",
      "1907779576417363396,\"\",6229\n",
      "5730251990344211405,\"\",6019\n",
      "7280399273658728997,\"\",6015\n",
      "835157184735512989,\"\",5209\n",
      "823824530034798601,\"\",2897\n",
      "938290163257834024,\"\",2684\n",
      "4931847376428061501,\"\",2537\n",
      "6949028786848070043,\"\",2496\n",
      "2763860660987168393,\"\",2179\n",
      "\n",
      "Polars time: 0.2002735137939453\n",
      "Polars return:\n",
      " shape: (10, 3)\n",
      "┌─────────────────────┬──────────────┬───────┐\n",
      "│ UserID              ┆ SearchPhrase ┆ count │\n",
      "│ ---                 ┆ ---          ┆ ---   │\n",
      "│ i64                 ┆ str          ┆ u32   │\n",
      "╞═════════════════════╪══════════════╪═══════╡\n",
      "│ 1313338681122956954 ┆              ┆ 15792 │\n",
      "│ 1907779576417363396 ┆              ┆ 6229  │\n",
      "│ 5730251990344211405 ┆              ┆ 6019  │\n",
      "│ 7280399273658728997 ┆              ┆ 6015  │\n",
      "│ 835157184735512989  ┆              ┆ 5209  │\n",
      "│ 823824530034798601  ┆              ┆ 2897  │\n",
      "│ 938290163257834024  ┆              ┆ 2684  │\n",
      "│ 4931847376428061501 ┆              ┆ 2537  │\n",
      "│ 6949028786848070043 ┆              ┆ 2496  │\n",
      "│ 2763860660987168393 ┆              ┆ 2179  │\n",
      "└─────────────────────┴──────────────┴───────┘\n",
      "Q17 SELECT UserID, SearchPhrase, COUNT(*) FROM hits GROUP BY UserID, SearchPhrase LIMIT 10;\n",
      "Pandas time: 2.7518060207366943\n",
      "Pandas return:\n",
      " UserID                SearchPhrase                              \n",
      "-9223344277659414581                                                1\n",
      "                      банкомитетаться обзор напитанов               1\n",
      "-9223178030934747259                                                2\n",
      "-9223054401365629534                                                4\n",
      "-9223019776173944577                                                3\n",
      "-9222967852064643611                                                1\n",
      "-9222533007323865344  админивэна в материи бесплатно в хорошем к    1\n",
      "-9222500201428208294                                                1\n",
      "-9222499855151233211  двигательная                                  1\n",
      "-9222343920573852356                                                1\n",
      "dtype: int64\n",
      "DuckDB time: 0.14226555824279785\n",
      "DuckDB return:\n",
      "                 UserID                                       SearchPhrase  \\\n",
      "0  2067839734864177164             можно в хорошем качественности, рязани   \n",
      "1  2067911873864507048                                                      \n",
      "2  2067982467443095417                                            большая   \n",
      "3  2068028751116662709                                         страйк все   \n",
      "4  2068385428180252259                                                      \n",
      "5  2068785294410515426  audia dell versionald games/inter to thickelba...   \n",
      "6  2069137487120986808                                                      \n",
      "7  2069532975163795814          так вы без погода в москва округалии лета   \n",
      "8  2070057092221630566                                                      \n",
      "9  2070768471638969442                                                      \n",
      "\n",
      "   count_star()  \n",
      "0             1  \n",
      "1             5  \n",
      "2             1  \n",
      "3             1  \n",
      "4             3  \n",
      "5             1  \n",
      "6             1  \n",
      "7             1  \n",
      "8             1  \n",
      "9             3  \n",
      "chDB time: 0.1154947280883789\n",
      "chDB return:\n",
      " 5742717625414611048,\"\",8\n",
      "606822877990268040,\"\",12\n",
      "5018087054317440147,\"как устанонс мобиля\",1\n",
      "129826221932705812,\"вишней омлет девочка+разгромка\",1\n",
      "2042388960092399588,\"лучшие фильтрумента в в просмотреть\",1\n",
      "7186620158467454830,\"\",29\n",
      "202455993298910909,\"гост себя любимом с над ypoвнем новгороде 2\",1\n",
      "6554463836776792292,\"туры и крышу себя сыне смотреть\",2\n",
      "9154614177984085670,\"\",1\n",
      "831971788620719538,\"\",10\n",
      "\n",
      "Polars time: 0.11278939247131348\n",
      "Polars return:\n",
      " shape: (10, 3)\n",
      "┌─────────────────────┬──────────────┬─────┐\n",
      "│ UserID              ┆ SearchPhrase ┆ len │\n",
      "│ ---                 ┆ ---          ┆ --- │\n",
      "│ i64                 ┆ str          ┆ u32 │\n",
      "╞═════════════════════╪══════════════╪═════╡\n",
      "│ 5988593630065757268 ┆              ┆ 2   │\n",
      "│ 1513436774088293151 ┆              ┆ 2   │\n",
      "│ 5864358838903309618 ┆              ┆ 8   │\n",
      "│ 716033621076183704  ┆              ┆ 14  │\n",
      "│ 916057460362160912  ┆              ┆ 2   │\n",
      "│ 1100534328207389682 ┆              ┆ 1   │\n",
      "│ 3265508986319153327 ┆              ┆ 2   │\n",
      "│ 1048348760838071640 ┆              ┆ 1   │\n",
      "│ 1355522988708024425 ┆              ┆ 17  │\n",
      "│ 5174039745845605041 ┆              ┆ 1   │\n",
      "└─────────────────────┴──────────────┴─────┘\n",
      "Q18 SELECT UserID, extract(minute FROM EventTime) AS m, SearchPhrase, COUNT(*) FROM hits GROUP BY UserID, m, SearchPhrase ORDER BY COUNT(*) DESC LIMIT 10;\n",
      "Pandas time: 54.36725902557373\n",
      "Pandas return:\n",
      " UserID               EventTime  SearchPhrase\n",
      "1313338681122956954  33                         324\n",
      "                     30                         323\n",
      "                     28                         314\n",
      "                     31                         311\n",
      "                     29                         308\n",
      "                     34                         306\n",
      "                     32                         302\n",
      "                     12                         296\n",
      "                     27                         296\n",
      "                     8                          294\n",
      "dtype: int64\n",
      "DuckDB time: 0.2024822235107422\n",
      "DuckDB return:\n",
      "                 UserID   m SearchPhrase  count_star()\n",
      "0  1313338681122956954  33                        324\n",
      "1  1313338681122956954  30                        323\n",
      "2  1313338681122956954  28                        314\n",
      "3  1313338681122956954  31                        311\n",
      "4  1313338681122956954  29                        308\n",
      "5  1313338681122956954  34                        306\n",
      "6  1313338681122956954  32                        302\n",
      "7  1313338681122956954  12                        296\n",
      "8  1313338681122956954  27                        296\n",
      "9  1313338681122956954  10                        294\n",
      "chDB time: 0.195556640625\n",
      "chDB return:\n",
      " 1313338681122956954,33,\"\",324\n",
      "1313338681122956954,30,\"\",323\n",
      "1313338681122956954,28,\"\",314\n",
      "1313338681122956954,31,\"\",311\n",
      "1313338681122956954,29,\"\",308\n",
      "1313338681122956954,34,\"\",306\n",
      "1313338681122956954,32,\"\",302\n",
      "1313338681122956954,12,\"\",296\n",
      "1313338681122956954,27,\"\",296\n",
      "1313338681122956954,10,\"\",294\n",
      "\n",
      "Polars time: 0.4637932777404785\n",
      "Polars return:\n",
      " shape: (10, 4)\n",
      "┌─────────────────────┬───────────┬──────────────┬───────┐\n",
      "│ UserID              ┆ EventTime ┆ SearchPhrase ┆ count │\n",
      "│ ---                 ┆ ---       ┆ ---          ┆ ---   │\n",
      "│ i64                 ┆ i8        ┆ str          ┆ u32   │\n",
      "╞═════════════════════╪═══════════╪══════════════╪═══════╡\n",
      "│ 1313338681122956954 ┆ 33        ┆              ┆ 324   │\n",
      "│ 1313338681122956954 ┆ 30        ┆              ┆ 323   │\n",
      "│ 1313338681122956954 ┆ 28        ┆              ┆ 314   │\n",
      "│ 1313338681122956954 ┆ 31        ┆              ┆ 311   │\n",
      "│ 1313338681122956954 ┆ 29        ┆              ┆ 308   │\n",
      "│ 1313338681122956954 ┆ 34        ┆              ┆ 306   │\n",
      "│ 1313338681122956954 ┆ 32        ┆              ┆ 302   │\n",
      "│ 1313338681122956954 ┆ 27        ┆              ┆ 296   │\n",
      "│ 1313338681122956954 ┆ 12        ┆              ┆ 296   │\n",
      "│ 1313338681122956954 ┆ 8         ┆              ┆ 294   │\n",
      "└─────────────────────┴───────────┴──────────────┴───────┘\n",
      "Q19 SELECT UserID FROM hits WHERE UserID = 435090932899640449;\n",
      "Pandas time: 0.0063283443450927734\n",
      "Pandas return:\n",
      " Empty DataFrame\n",
      "Columns: [WatchID, JavaEnable, Title, GoodEvent, EventTime, EventDate, CounterID, ClientIP, RegionID, UserID, CounterClass, OS, UserAgent, URL, Referer, IsRefresh, RefererCategoryID, RefererRegionID, URLCategoryID, URLRegionID, ResolutionWidth, ResolutionHeight, ResolutionDepth, FlashMajor, FlashMinor, FlashMinor2, NetMajor, NetMinor, UserAgentMajor, UserAgentMinor, CookieEnable, JavascriptEnable, IsMobile, MobilePhone, MobilePhoneModel, Params, IPNetworkID, TraficSourceID, SearchEngineID, SearchPhrase, AdvEngineID, IsArtifical, WindowClientWidth, WindowClientHeight, ClientTimeZone, ClientEventTime, SilverlightVersion1, SilverlightVersion2, SilverlightVersion3, SilverlightVersion4, PageCharset, CodeVersion, IsLink, IsDownload, IsNotBounce, FUniqID, OriginalURL, HID, IsOldCounter, IsEvent, IsParameter, DontCountHits, WithHash, HitColor, LocalEventTime, Age, Sex, Income, Interests, Robotness, RemoteIP, WindowName, OpenerName, HistoryLength, BrowserLanguage, BrowserCountry, SocialNetwork, SocialAction, HTTPError, SendTiming, DNSTiming, ConnectTiming, ResponseStartTiming, ResponseEndTiming, FetchTiming, SocialSourceNetworkID, SocialSourcePage, ParamPrice, ParamOrderID, ParamCurrency, ParamCurrencyID, OpenstatServiceName, OpenstatCampaignID, OpenstatAdID, OpenstatSourceID, UTMSource, UTMMedium, UTMCampaign, UTMContent, UTMTerm, ...]\n",
      "Index: []\n",
      "\n",
      "[0 rows x 105 columns]\n",
      "DuckDB time: 0.02909088134765625\n",
      "DuckDB return:\n",
      " Empty DataFrame\n",
      "Columns: [UserID]\n",
      "Index: []\n",
      "chDB time: 0.023262739181518555\n",
      "chDB return:\n",
      " \n",
      "Polars time: 0.006215810775756836\n",
      "Polars return:\n",
      " shape: (0, 105)\n",
      "┌─────────┬────────────┬───────┬───────────┬───┬──────────┬─────────────┬─────────┬──────┐\n",
      "│ WatchID ┆ JavaEnable ┆ Title ┆ GoodEvent ┆ … ┆ HasGCLID ┆ RefererHash ┆ URLHash ┆ CLID │\n",
      "│ ---     ┆ ---        ┆ ---   ┆ ---       ┆   ┆ ---      ┆ ---         ┆ ---     ┆ ---  │\n",
      "│ i64     ┆ i16        ┆ str   ┆ i16       ┆   ┆ i16      ┆ i64         ┆ i64     ┆ i32  │\n",
      "╞═════════╪════════════╪═══════╪═══════════╪═══╪══════════╪═════════════╪═════════╪══════╡\n",
      "└─────────┴────────────┴───────┴───────────┴───┴──────────┴─────────────┴─────────┴──────┘\n",
      "Q20 SELECT COUNT(*) FROM hits WHERE URL LIKE '%google%';\n",
      "Pandas time: 2.1297006607055664\n",
      "Pandas return:\n",
      " 1687\n",
      "DuckDB time: 0.12494659423828125\n",
      "DuckDB return:\n",
      "    count_star()\n",
      "0          1687\n",
      "chDB time: 0.08678507804870605\n",
      "chDB return:\n",
      " 1687\n",
      "\n",
      "Polars time: 0.18349432945251465\n",
      "Polars return:\n",
      " 1687\n",
      "Q21 SELECT SearchPhrase, MIN(URL), COUNT(*) AS c FROM hits WHERE URL LIKE '%google%' AND SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY c DESC LIMIT 10;\n",
      "Pandas time: 2.5472168922424316\n",
      "Pandas return:\n",
      "                                                                                                   URL  \\\n",
      "SearchPhrase                                                                                            \n",
      "римском качественны for cry                                         http:%2F%2Fwwww.googlead&aktional   \n",
      "рецепты салдингал иркутске дом в при                                http:%2F%2Fwwww.googlead&aktional   \n",
      "тест драмы смотреть                                                 http:%2F%2Fwwww.googlead&aktional   \n",
      "испанч боб новости дейская                          http://smeshariki.ru/recipes/show/6840872&traf...   \n",
      "dynamic gigabyte-kuzbassassins 6 полос              http://forum2/play.google.ru/main.aspx?brands][1]   \n",
      "dynamic gigabyte-kuzbassassins 6 получение сери...  http://forum2/play.google.ru/main.aspx?brands][1]   \n",
      "dynamic gigabyte-kuzbassassins 6 получение сери...  http://forum2/play.google.ru/main.aspx?brands][1]   \n",
      "маски в горает устантиров в работа поездки видео    http://forum2/play.google.ru/main.aspx?brands][1]   \n",
      "обезболи все переватель 2gis.ru/ha отзывы               http://sslovarenovyy-s-koroshen_apps.googleBR   \n",
      "оборт                                               http://forum2/play.google/eduabroad_input_bdsm...   \n",
      "\n",
      "                                                    SearchPhrase  \n",
      "SearchPhrase                                                      \n",
      "римском качественны for cry                                   24  \n",
      "рецепты салдингал иркутске дом в при                           6  \n",
      "тест драмы смотреть                                            6  \n",
      "испанч боб новости дейская                                     5  \n",
      "dynamic gigabyte-kuzbassassins 6 полос                         4  \n",
      "dynamic gigabyte-kuzbassassins 6 получение сери...             4  \n",
      "dynamic gigabyte-kuzbassassins 6 получение сери...             3  \n",
      "маски в горает устантиров в работа поездки видео               3  \n",
      "обезболи все переватель 2gis.ru/ha отзывы                      3  \n",
      "оборт                                                          3  \n",
      "DuckDB time: 0.12578415870666504\n",
      "DuckDB return:\n",
      "                                         SearchPhrase  \\\n",
      "0                        римском качественны for cry   \n",
      "1                                тест драмы смотреть   \n",
      "2               рецепты салдингал иркутске дом в при   \n",
      "3                         испанч боб новости дейская   \n",
      "4  dynamic gigabyte-kuzbassassins 6 получение сер...   \n",
      "5             dynamic gigabyte-kuzbassassins 6 полос   \n",
      "6   маски в горает устантиров в работа поездки видео   \n",
      "7                                              оборт   \n",
      "8                              римского духово-зуево   \n",
      "9  dynamic gigabyte-kuzbassassins 6 получение сер...   \n",
      "\n",
      "                                            min(URL)   c  \n",
      "0                  http:%2F%2Fwwww.googlead&aktional  24  \n",
      "1                  http:%2F%2Fwwww.googlead&aktional   6  \n",
      "2                  http:%2F%2Fwwww.googlead&aktional   6  \n",
      "3  http://smeshariki.ru/recipes/show/6840872&traf...   5  \n",
      "4  http://forum2/play.google.ru/main.aspx?brands][1]   4  \n",
      "5  http://forum2/play.google.ru/main.aspx?brands][1]   4  \n",
      "6  http://forum2/play.google.ru/main.aspx?brands][1]   3  \n",
      "7  http://forum2/play.google/eduabroad_input_bdsm...   3  \n",
      "8                  http:%2F%2Fwwww.googlead&aktional   3  \n",
      "9  http://forum2/play.google.ru/main.aspx?brands][1]   3  \n",
      "chDB time: 0.11338138580322266\n",
      "chDB return:\n",
      " \"римском качественны for cry\",\"http:%2F%2Fwwww.googlead&aktional\",24\n",
      "\"тест драмы смотреть\",\"http:%2F%2Fwwww.googlead&aktional\",6\n",
      "\"рецепты салдингал иркутске дом в при\",\"http:%2F%2Fwwww.googlead&aktional\",6\n",
      "\"испанч боб новости дейская\",\"http://smeshariki.ru/recipes/show/6840872&trafkey=6d0fc12c54059/loukhaAUXI&where=all&filter/Mitsubishi/google\",5\n",
      "\"dynamic gigabyte-kuzbassassins 6 полос\",\"http://forum2/play.google.ru/main.aspx?brands][1]\",4\n",
      "\"dynamic gigabyte-kuzbassassins 6 получение серия сперминат машинки\",\"http://forum2/play.google.ru/main.aspx?brands][1]\",4\n",
      "\"обезболи все переватель 2gis.ru/ha отзывы\",\"http://sslovarenovyy-s-koroshen_apps.googleBR\",3\n",
      "\"оборт\",\"http://forum2/play.google/eduabroad_input_bdsmpeople\",3\n",
      "\"маски в горает устантиров в работа поездки видео\",\"http://forum2/play.google.ru/main.aspx?brands][1]\",3\n",
      "\"dynamic gigabyte-kuzbassassins 6 получение серия сперми\",\"http://forum2/play.google.ru/main.aspx?brands][1]\",3\n",
      "\n",
      "Polars time: 0.18537497520446777\n",
      "Polars return:\n",
      " shape: (10, 3)\n",
      "┌─────────────────────────────────┬─────────────────────────────────┬───────┐\n",
      "│ SearchPhrase                    ┆ URL                             ┆ count │\n",
      "│ ---                             ┆ ---                             ┆ ---   │\n",
      "│ str                             ┆ str                             ┆ u32   │\n",
      "╞═════════════════════════════════╪═════════════════════════════════╪═══════╡\n",
      "│ римском качественны for cry     ┆ http:%2F%2Fwwww.googlead&aktio… ┆ 24    │\n",
      "│ тест драмы смотреть             ┆ http:%2F%2Fwwww.googlead&aktio… ┆ 6     │\n",
      "│ рецепты салдингал иркутске дом… ┆ http:%2F%2Fwwww.googlead&aktio… ┆ 6     │\n",
      "│ испанч боб новости дейская      ┆ http://smeshariki.ru/recipes/s… ┆ 5     │\n",
      "│ dynamic gigabyte-kuzbassassins… ┆ http://forum2/play.google.ru/m… ┆ 4     │\n",
      "│ dynamic gigabyte-kuzbassassins… ┆ http://forum2/play.google.ru/m… ┆ 4     │\n",
      "│ маски в горает устантиров в ра… ┆ http://forum2/play.google.ru/m… ┆ 3     │\n",
      "│ римского духово-зуево           ┆ http:%2F%2Fwwww.googlead&aktio… ┆ 3     │\n",
      "│ обезболи все переватель 2gis.r… ┆ http://sslovarenovyy-s-koroshe… ┆ 3     │\n",
      "│ оборт                           ┆ http://forum2/play.google/edua… ┆ 3     │\n",
      "└─────────────────────────────────┴─────────────────────────────────┴───────┘\n",
      "Q22 SELECT SearchPhrase, MIN(URL), MIN(Title), COUNT(*) AS c, COUNT(DISTINCT UserID) FROM hits WHERE Title LIKE '%Google%' AND URL NOT LIKE '%.google.%' AND SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY c DESC LIMIT 10;\n",
      "Pandas time: 8.950557470321655\n",
      "Pandas return:\n",
      "                                                                                                   URL  \\\n",
      "SearchPhrase                                                                                            \n",
      "винки медведь смотреть фильмы 2013 смотреть         http://smeshariki.ru/a-folder-4/#page-3.2.1; W...   \n",
      "винки медведь смотреть фильмы чеческия              http://smeshariki.ru/a-folder-4/#page-3.2.1; W...   \n",
      "винки медведь смотреть объятный ветерин             http://smeshariki.ru/index.ua/newsru.com/ifram...   \n",
      "кино 2009) смотреть онлайн бессмерти мк в россипед                http://domchelove.ru/#!/search/page   \n",
      "коптимиквиды юриста с роуз рая                      https://produkty%2Fpulove.ru/booklyattion-war-...   \n",
      "коптимиквиды юрий жд ворожные моем                  https://produkty%2Fpulove.ru/booklyattion-war-...   \n",
      "самаре на мира матки видео 21.03.2013 смотреть      http://smeshariki.ru/GameMain.aspx#location.ru...   \n",
      "ведомосквиталия страции                             https://produkty%2Fpulove.ru/booklyattion-war-...   \n",
      "винки медведь смотреть                              http://smeshariki.ru/index.ua/newsru.com/ifram...   \n",
      "тайны избавитель в владимира для университет ма...  http://smeshariki.ru/index.ua/baby=1&with_exch...   \n",
      "\n",
      "                                                                                                Title  \\\n",
      "SearchPhrase                                                                                            \n",
      "винки медведь смотреть фильмы 2013 смотреть                                     видеорегионалу Google   \n",
      "винки медведь смотреть фильмы чеческия              видеорегионалу Google - Досториа Базар автомоб...   \n",
      "винки медведь смотреть объятный ветерин              видеорегионалу Google Gel - Курганизмом, дачи -    \n",
      "кино 2009) смотреть онлайн бессмерти мк в россипед  Далее о коллекции в GIMI LANCIA 0K3Y318104 про...   \n",
      "коптимиквиды юриста с роуз рая                      Легко на участные участников., Цены - Стильная...   \n",
      "коптимиквиды юрий жд ворожные моем                  Легко на участные участников., Цены - Стильная...   \n",
      "самаре на мира матки видео 21.03.2013 смотреть      Квартиры в проекты - Google rientalie Goal!, 2...   \n",
      "ведомосквиталия страции                             Легко на участные участников., Цены - Стильная...   \n",
      "винки медведь смотреть                                  видеорегионалу Google - модного языке - Пульс   \n",
      "тайны избавитель в владимира для университет ма...  Амитин обувь - Яндекс.Видео+текст песен Google...   \n",
      "\n",
      "                                                    SearchPhrase  UserID  \n",
      "SearchPhrase                                                              \n",
      "винки медведь смотреть фильмы 2013 смотреть                  112      81  \n",
      "винки медведь смотреть фильмы чеческия                        21      18  \n",
      "винки медведь смотреть объятный ветерин                       14      10  \n",
      "кино 2009) смотреть онлайн бессмерти мк в россипед            13       9  \n",
      "коптимиквиды юриста с роуз рая                                12       3  \n",
      "коптимиквиды юрий жд ворожные моем                             8       2  \n",
      "самаре на мира матки видео 21.03.2013 смотреть                 7       1  \n",
      "ведомосквиталия страции                                        6       2  \n",
      "винки медведь смотреть                                         6       4  \n",
      "тайны избавитель в владимира для университет ма...             6       4  \n",
      "DuckDB time: 0.23342061042785645\n",
      "DuckDB return:\n",
      "                                         SearchPhrase  \\\n",
      "0        винки медведь смотреть фильмы 2013 смотреть   \n",
      "1             винки медведь смотреть фильмы чеческия   \n",
      "2            винки медведь смотреть объятный ветерин   \n",
      "3  кино 2009) смотреть онлайн бессмерти мк в росс...   \n",
      "4                     коптимиквиды юриста с роуз рая   \n",
      "5                 коптимиквиды юрий жд ворожные моем   \n",
      "6     самаре на мира матки видео 21.03.2013 смотреть   \n",
      "7  тайны избавитель в владимира для университет м...   \n",
      "8                            ведомосквиталия страции   \n",
      "9                             винки медведь смотреть   \n",
      "\n",
      "                                            min(URL)  \\\n",
      "0  http://smeshariki.ru/a-folder-4/#page-3.2.1; W...   \n",
      "1  http://smeshariki.ru/a-folder-4/#page-3.2.1; W...   \n",
      "2  http://smeshariki.ru/index.ua/newsru.com/ifram...   \n",
      "3                http://domchelove.ru/#!/search/page   \n",
      "4  https://produkty%2Fpulove.ru/booklyattion-war-...   \n",
      "5  https://produkty%2Fpulove.ru/booklyattion-war-...   \n",
      "6  http://smeshariki.ru/GameMain.aspx#location.ru...   \n",
      "7  http://smeshariki.ru/index.ua/baby=1&with_exch...   \n",
      "8  https://produkty%2Fpulove.ru/booklyattion-war-...   \n",
      "9  http://smeshariki.ru/index.ua/newsru.com/ifram...   \n",
      "\n",
      "                                          min(Title)    c  \\\n",
      "0                              видеорегионалу Google  112   \n",
      "1  видеорегионалу Google - Досториа Базар автомоб...   21   \n",
      "2   видеорегионалу Google Gel - Курганизмом, дачи -    14   \n",
      "3  Далее о коллекции в GIMI LANCIA 0K3Y318104 про...   13   \n",
      "4  Легко на участные участников., Цены - Стильная...   12   \n",
      "5  Легко на участные участников., Цены - Стильная...    8   \n",
      "6  Квартиры в проекты - Google rientalie Goal!, 2...    7   \n",
      "7  Амитин обувь - Яндекс.Видео+текст песен Google...    6   \n",
      "8  Легко на участные участников., Цены - Стильная...    6   \n",
      "9      видеорегионалу Google - модного языке - Пульс    6   \n",
      "\n",
      "   count(DISTINCT UserID)  \n",
      "0                      81  \n",
      "1                      18  \n",
      "2                      10  \n",
      "3                       9  \n",
      "4                       3  \n",
      "5                       2  \n",
      "6                       1  \n",
      "7                       4  \n",
      "8                       2  \n",
      "9                       4  \n",
      "chDB time: 0.18370819091796875\n",
      "chDB return:\n",
      " \"винки медведь смотреть фильмы 2013 смотреть\",\"http://smeshariki.ru/a-folder-4/#page-3.2.1; WOW64; Edition=1&input_age2/#over-1.3.adfox.ru/image=0&engineVolumeFrom\",\"видеорегионалу Google\",112,81\n",
      "\"винки медведь смотреть фильмы чеческия\",\"http://smeshariki.ru/a-folder-4/#page-3.2.1; WOW64; Edition=1&input_age2/?page_type=cated_card_330709_1_116105812\",\"видеорегионалу Google - Досториа Базар автомобили купить манские характеринбу\",21,18\n",
      "\"винки медведь смотреть объятный ветерин\",\"http://smeshariki.ru/index.ua/newsru.com/iframe_right%3D43%26bt%3D278885%26bid%3D278885%26bid%3D0%26nid%3D0%26rnd%3D1216/0001-04/19442-173-recentry=&op_product\",\"видеорегионалу Google Gel - Курганизмом, дачи - \",14,10\n",
      "\"кино 2009) смотреть онлайн бессмерти мк в россипед\",\"http://domchelove.ru/#!/search/page\",\"Далее о коллекции в GIMI LANCIA 0K3Y318104 продать Google, go-go в регистрии — Мой Крым\",13,9\n",
      "\"коптимиквиды юриста с роуз рая\",\"https://produkty%2Fpulove.ru/booklyattion-war-sinij-9182/women\",\"Легко на участные участников., Цены - Стильная парнем. Саганрог догадения : Турции, купить у 10 дне кольные машинки не представки - Новая с избиение спродажа: котята 2014 г.в. Цена: 47500-10ECO060 – -------- купить квартиру Оренбург (России Galantrax Flamiliada Google, Nо 18 фотоконверк Супер Кардиган\",12,3\n",
      "\"коптимиквиды юрий жд ворожные моем\",\"https://produkty%2Fpulove.ru/booklyattion-war-sinij-9182/women\",\"Легко на участные участников., Цены - Стильная парнем. Саганрог догадения : Турции, купить у 10 дне кольные машинки не представки - Новая с избиение спродажа: котята 2014 г.в. Цена: 47500-10ECO060 – -------- купить квартиру Оренбург (России Galantrax Flamiliada Google, Nо 18 фотоконверк Супер Кардиган\",8,2\n",
      "\"самаре на мира матки видео 21.03.2013 смотреть\",\"http://smeshariki.ru/GameMain.aspx#location.ru/anketa.by/01/00101\",\"Квартиры в проекты - Google rientalie Goal!, 2002 г.в. Цена: 400 общая 66 (626) 1989 г.в. ( 1599$, (г. Доминиров VLC medved out Dlya versplay в боль, Красный\",7,1\n",
      "\"ведомосквиталия страции\",\"https://produkty%2Fpulove.ru/booklyattion-war-sinij-9182/women\",\"Легко на участные участников., Цены - Стильная парнем. Саганрог догадения : Турции, купить у 10 дне кольные машинки не представки - Новая с избиение спродажа: котята 2014 г.в. Цена: 47500-10ECO060 – -------- купить квартиру Оренбург (России Galantrax Flamiliada Google, Nо 18 фотоконверк Супер Кардиган\",6,2\n",
      "\"винки медведь смотреть\",\"http://smeshariki.ru/index.ua/newsru.com/iframe_right%3D43%26bt%3D90%26nid%3D8235.html?1=1&cid=147960&wi=1280&lo=http://video.yandex\",\"видеорегионалу Google - модного языке - Пульс\",6,4\n",
      "\"юрий духовиковый тумбой магазин\",\"http://video.yandex.ru/ch/meters=0&price_do=&currency\",\"Ежедневное - Пульс цены | купить ул., доступные Челябинский рифленогопользовать Audio - Компании Google Agila дорабль в\",6,6\n",
      "\n",
      "Polars time: 0.36249494552612305\n",
      "Polars return:\n",
      " shape: (10, 5)\n",
      "┌───────────────────────────┬──────────────────────────┬──────────────────────────┬───────┬────────┐\n",
      "│ SearchPhrase              ┆ URL                      ┆ Title                    ┆ count ┆ UserID │\n",
      "│ ---                       ┆ ---                      ┆ ---                      ┆ ---   ┆ ---    │\n",
      "│ str                       ┆ str                      ┆ str                      ┆ u32   ┆ u32    │\n",
      "╞═══════════════════════════╪══════════════════════════╪══════════════════════════╪═══════╪════════╡\n",
      "│ винки медведь смотреть    ┆ http://smeshariki.ru/a-f ┆ видеорегионалу Google    ┆ 112   ┆ 81     │\n",
      "│ фильмы …                  ┆ older-…                  ┆                          ┆       ┆        │\n",
      "│ винки медведь смотреть    ┆ http://smeshariki.ru/a-f ┆ видеорегионалу Google -  ┆ 21    ┆ 18     │\n",
      "│ фильмы …                  ┆ older-…                  ┆ Достор…                  ┆       ┆        │\n",
      "│ винки медведь смотреть    ┆ http://smeshariki.ru/ind ┆ видеорегионалу Google    ┆ 14    ┆ 10     │\n",
      "│ объятны…                  ┆ ex.ua/…                  ┆ Gel - Ку…                ┆       ┆        │\n",
      "│ кино 2009) смотреть       ┆ http://domchelove.ru/#!/ ┆ Далее о коллекции в GIMI ┆ 13    ┆ 9      │\n",
      "│ онлайн бес…               ┆ search…                  ┆ LANCI…                   ┆       ┆        │\n",
      "│ коптимиквиды юриста с     ┆ https://produkty%2Fpulov ┆ Легко на участные        ┆ 12    ┆ 3      │\n",
      "│ роуз рая                  ┆ e.ru/b…                  ┆ участников.,…            ┆       ┆        │\n",
      "│ коптимиквиды юрий жд      ┆ https://produkty%2Fpulov ┆ Легко на участные        ┆ 8     ┆ 2      │\n",
      "│ ворожные …                ┆ e.ru/b…                  ┆ участников.,…            ┆       ┆        │\n",
      "│ самаре на мира матки      ┆ http://smeshariki.ru/Gam ┆ Квартиры в проекты -     ┆ 7     ┆ 1      │\n",
      "│ видео 21.…                ┆ eMain.…                  ┆ Google ri…               ┆       ┆        │\n",
      "│ юрий духовиковый тумбой   ┆ http://video.yandex.ru/c ┆ Ежедневное - Пульс цены  ┆ 6     ┆ 6      │\n",
      "│ магази…                   ┆ h/mete…                  ┆ | купи…                  ┆       ┆        │\n",
      "│ тайны избавитель в        ┆ http://smeshariki.ru/ind ┆ Амитин обувь -           ┆ 6     ┆ 4      │\n",
      "│ владимира д…              ┆ ex.ua/…                  ┆ Яндекс.Видео+те…         ┆       ┆        │\n",
      "│ винки медведь смотреть    ┆ http://smeshariki.ru/ind ┆ видеорегионалу Google -  ┆ 6     ┆ 4      │\n",
      "│                           ┆ ex.ua/…                  ┆ модног…                  ┆       ┆        │\n",
      "└───────────────────────────┴──────────────────────────┴──────────────────────────┴───────┴────────┘\n",
      "Q23 SELECT * FROM hits WHERE URL LIKE '%google%' ORDER BY EventTime LIMIT 10;\n",
      "Pandas time: 2.123731851577759\n",
      "Pandas return:\n",
      "                      WatchID  JavaEnable  \\\n",
      "8858875  7106264041910208868           1   \n",
      "8896307  6801361853621701142           1   \n",
      "8896308  7370235307579469118           1   \n",
      "9646993  7299686183082339643           1   \n",
      "9646995  5241207090454501610           1   \n",
      "9646996  8762858360217969903           1   \n",
      "8937843  5937582489445775385           1   \n",
      "9656506  5585474130921985177           1   \n",
      "9656507  8119609642256502216           1   \n",
      "9619305  8851521334882706019           0   \n",
      "\n",
      "                                                     Title  GoodEvent  \\\n",
      "8858875  ГОСТЕЛЬНОЗЕРОГ ГОРНЫЙ ДОЖДЬ! - Спорт, алюминис...          1   \n",
      "8896307  Смешарики SW | SexWife: Женщин - Яндекс.Афиша@...          1   \n",
      "8896308                                                             1   \n",
      "9646993  Торт и продам Ford (Форд - IRR.ru (Работа и ро...          1   \n",
      "9646995  Торт и продам Ford (Форд - IRR.ru (Работа и ро...          1   \n",
      "9646996                                                             1   \n",
      "8937843                          прода. Поиск повый бизнес          1   \n",
      "9656506  Торт и продам Ford (Форд - IRR.ru (Работа и ро...          1   \n",
      "9656507                                                             1   \n",
      "9619305  Вопростовый стал Петербурге. Последников в про...          1   \n",
      "\n",
      "                  EventTime  EventDate  CounterID    ClientIP  RegionID  \\\n",
      "8858875 2013-07-01 23:31:03 2013-07-02      46429  1249584689       229   \n",
      "8896307 2013-07-01 23:44:01 2013-07-02      40367 -1231921306         2   \n",
      "8896308 2013-07-01 23:44:14 2013-07-02      40367 -1231921306         2   \n",
      "9646993 2013-07-01 23:59:17 2013-07-02      46429  1553640326       115   \n",
      "9646995 2013-07-02 01:59:29 2013-07-02      46429  1553640326       115   \n",
      "9646996 2013-07-02 01:59:42 2013-07-02      46429  1553640326       115   \n",
      "8937843 2013-07-02 02:46:42 2013-07-02      63621 -1801466482       229   \n",
      "9656506 2013-07-02 02:50:56 2013-07-02      46429 -1366734181        44   \n",
      "9656507 2013-07-02 02:51:09 2013-07-02      46429 -1366734181        44   \n",
      "9619305 2013-07-02 05:18:07 2013-07-02      39641  1897404057        12   \n",
      "\n",
      "                      UserID  ...   UTMSource  UTMMedium      UTMCampaign  \\\n",
      "8858875    72720560134547761  ...                                           \n",
      "8896307   434272054218180613  ...                                           \n",
      "8896308   434272054218180613  ...                                           \n",
      "9646993   168449836300271247  ...                                           \n",
      "9646995   168449836300271247  ...  feedburner     banner  ad_cpamarketing   \n",
      "9646996   168449836300271247  ...  feedburner     banner  ad_cpamarketing   \n",
      "8937843  5639771411007874048  ...                                           \n",
      "9656506  6484173929977037196  ...                                           \n",
      "9656507  6484173929977037196  ...                                           \n",
      "9619305  2147819122923023112  ...                                           \n",
      "\n",
      "        UTMContent UTMTerm  FromTag  HasGCLID          RefererHash  \\\n",
      "8858875                                     0 -3651842497912472547   \n",
      "8896307                                     0  5673263859390493714   \n",
      "8896308                                     0  -296158784638538920   \n",
      "9646993                                     0 -2923571516118524499   \n",
      "9646995                                     0  4719160989640449379   \n",
      "9646996                                     0  -296158784638538920   \n",
      "8937843                                     0   532293348752290058   \n",
      "9656506                                     0   -43688538285913943   \n",
      "9656507                                     0  -296158784638538920   \n",
      "9619305                                     0  6285928018624721980   \n",
      "\n",
      "                     URLHash  CLID  \n",
      "8858875  5528743655405710480     0  \n",
      "8896307 -6433683654023857482     0  \n",
      "8896308 -6433683654023857482     0  \n",
      "9646993  1337795999976243980     0  \n",
      "9646995  2196566102793075843     0  \n",
      "9646996  2196566102793075843     0  \n",
      "8937843 -7069763488219331997     0  \n",
      "9656506  1337795999976243980     0  \n",
      "9656507  1337795999976243980     0  \n",
      "9619305 -6462309590271025210     0  \n",
      "\n",
      "[10 rows x 105 columns]\n",
      "DuckDB time: 0.47556400299072266\n",
      "DuckDB return:\n",
      "                WatchID  JavaEnable  \\\n",
      "0  7106264041910208868           1   \n",
      "1  6801361853621701142           1   \n",
      "2  7370235307579469118           1   \n",
      "3  7299686183082339643           1   \n",
      "4  5241207090454501610           1   \n",
      "5  8762858360217969903           1   \n",
      "6  5937582489445775385           1   \n",
      "7  5585474130921985177           1   \n",
      "8  8119609642256502216           1   \n",
      "9  8851521334882706019           0   \n",
      "\n",
      "                                               Title  GoodEvent  \\\n",
      "0  ГОСТЕЛЬНОЗЕРОГ ГОРНЫЙ ДОЖДЬ! - Спорт, алюминис...          1   \n",
      "1  Смешарики SW | SexWife: Женщин - Яндекс.Афиша@...          1   \n",
      "2                                                             1   \n",
      "3  Торт и продам Ford (Форд - IRR.ru (Работа и ро...          1   \n",
      "4  Торт и продам Ford (Форд - IRR.ru (Работа и ро...          1   \n",
      "5                                                             1   \n",
      "6                          прода. Поиск повый бизнес          1   \n",
      "7  Торт и продам Ford (Форд - IRR.ru (Работа и ро...          1   \n",
      "8                                                             1   \n",
      "9  Вопростовый стал Петербурге. Последников в про...          1   \n",
      "\n",
      "            EventTime  EventDate  CounterID    ClientIP  RegionID  \\\n",
      "0 2013-07-01 23:31:03 2013-07-02      46429  1249584689       229   \n",
      "1 2013-07-01 23:44:01 2013-07-02      40367 -1231921306         2   \n",
      "2 2013-07-01 23:44:14 2013-07-02      40367 -1231921306         2   \n",
      "3 2013-07-01 23:59:17 2013-07-02      46429  1553640326       115   \n",
      "4 2013-07-02 01:59:29 2013-07-02      46429  1553640326       115   \n",
      "5 2013-07-02 01:59:42 2013-07-02      46429  1553640326       115   \n",
      "6 2013-07-02 02:46:42 2013-07-02      63621 -1801466482       229   \n",
      "7 2013-07-02 02:50:56 2013-07-02      46429 -1366734181        44   \n",
      "8 2013-07-02 02:51:09 2013-07-02      46429 -1366734181        44   \n",
      "9 2013-07-02 05:18:07 2013-07-02      39641  1897404057        12   \n",
      "\n",
      "                UserID  ...   UTMSource  UTMMedium      UTMCampaign  \\\n",
      "0    72720560134547761  ...                                           \n",
      "1   434272054218180613  ...                                           \n",
      "2   434272054218180613  ...                                           \n",
      "3   168449836300271247  ...                                           \n",
      "4   168449836300271247  ...  feedburner     banner  ad_cpamarketing   \n",
      "5   168449836300271247  ...  feedburner     banner  ad_cpamarketing   \n",
      "6  5639771411007874048  ...                                           \n",
      "7  6484173929977037196  ...                                           \n",
      "8  6484173929977037196  ...                                           \n",
      "9  2147819122923023112  ...                                           \n",
      "\n",
      "  UTMContent UTMTerm  FromTag  HasGCLID          RefererHash  \\\n",
      "0                                     0 -3651842497912472547   \n",
      "1                                     0  5673263859390493714   \n",
      "2                                     0  -296158784638538920   \n",
      "3                                     0 -2923571516118524499   \n",
      "4                                     0  4719160989640449379   \n",
      "5                                     0  -296158784638538920   \n",
      "6                                     0   532293348752290058   \n",
      "7                                     0   -43688538285913943   \n",
      "8                                     0  -296158784638538920   \n",
      "9                                     0  6285928018624721980   \n",
      "\n",
      "               URLHash  CLID  \n",
      "0  5528743655405710480     0  \n",
      "1 -6433683654023857482     0  \n",
      "2 -6433683654023857482     0  \n",
      "3  1337795999976243980     0  \n",
      "4  2196566102793075843     0  \n",
      "5  2196566102793075843     0  \n",
      "6 -7069763488219331997     0  \n",
      "7  1337795999976243980     0  \n",
      "8  1337795999976243980     0  \n",
      "9 -6462309590271025210     0  \n",
      "\n",
      "[10 rows x 105 columns]\n",
      "chDB time: 0.4304678440093994\n",
      "chDB return:\n",
      " 7106264041910208868,1,\"ГОСТЕЛЬНОЗЕРОГ ГОРНЫЙ ДОЖДЬ! - Спорт, алюминистик : играй!!!! ЦЕНЫ!! фотоальбомы и океансов в продать-взять-о и видео#!/search?film.TV) — растер - : купить\",1,\"2013-07-02 07:31:03.000000000\",\"2013-07-02 08:00:00.000000000\",46429,1249584689,229,72720560134547761,0,44,46,\"http://smeshariki.ru/users/2013-07-15,2013&To=03.07.2013-07-01:2013-07-17545/content/searchivemix).mp3ex.net/page.google-plata.ru\",\"http://smeshariki.ru/page.aspx?Countforpartments/7416543000&currency=RUR/carpartner-peskie_kollen&item-1/nf-6\",0,16000,158,9911,216,1996,1781,37,15,7,\"700\",0,0,22,\"D�\",1,1,0,0,\"\",\"\",2221747,-1,0,\"\",0,0,1485,688,135,1372775257,4,0,46077,0,\"windows-1251;charset\",1601,0,0,0,6266009505159221854,\"\",1038228209,0,0,0,0,0,\"g\",1372737370,0,2,0,0,0,1184697127,36437,-1,2,\"S0\",\"�\f\",\"\",\"\",0,0,0,3,83,26,0,0,\"\",0,\"\",\"NH\u001c\",0,\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",0,-3651842497912472547,5528743655405710480,0\n",
      "6801361853621701142,1,\"Смешарики SW | SexWife: Женщин - Яндекс.Афиша@Mail.Ru - магазин модный Журнал: Абдельцев Honda с производств\",1,\"2013-07-02 07:44:01.000000000\",\"2013-07-02 08:00:00.000000000\",40367,-1231921306,2,434272054218180613,0,126,5,\"http://interinburg/detail.google,yandex.aspx#location=products\",\"http://yandex.ru/domkadrov.irr.ru/yandsearch&caU82MlBVHpMbWgwYld3JTNEZnRTYUh$MGNEb3ZMMmh2Ykc5YWf6VzcO3ZqI91PIqcL84YZg&bvm=bv.48705608,d.bGE&cad=rja&ved=0CEYQFjAD&url=http://rsdn.ru%2F~книги%2FКомпот и болгари\",0,14550,952,13164,16,1996,1781,37,15,7,\"700\",0,0,22,\"D�\",1,1,0,0,\"\",\"\",1999580,3,1,\"ани пух ходу\",0,0,567,577,135,1372784689,4,1,15738,0,\"windows\",1601,0,0,0,8352815799795997820,\"\",376469337,0,0,0,0,0,\"5\",1372759377,31,1,2,6,43,-815706743,-1,-1,-1,\"S0\",\"�\f\",\"\",\"\",0,0,0,0,453,45,0,0,\"\",0,\"\",\"NH\u001c\",0,\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",0,5673263859390493714,-6433683654023857482,0\n",
      "7370235307579469118,1,\"\",1,\"2013-07-02 07:44:14.000000000\",\"2013-07-02 08:00:00.000000000\",40367,-1231921306,2,434272054218180613,0,126,5,\"http://interinburg/detail.google,yandex.aspx#location=products\",\"\",0,0,0,13164,16,1996,1781,37,15,7,\"700\",0,0,22,\"D�\",1,1,0,0,\"\",\"\",1999580,0,0,\"\",0,1,567,577,135,1372784704,4,1,15738,0,\"windows\",1601,0,0,1,8352815799795997820,\"\",376469337,0,0,0,1,0,\"5\",1372759391,31,1,2,6,43,-815706743,-1,-1,-1,\"S0\",\"�\f\",\"\",\"\",0,441,0,0,0,0,0,0,\"\",0,\"\",\"NH\u001c\",0,\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",0,-296158784638538920,-6433683654023857482,0\n",
      "7299686183082339643,1,\"Торт и продам Ford (Форд - IRR.ru (Работа и роды (Clean Almera Money Spear Napa Roomantic (Сцены | квартира, ИЩУ КОГДАНА (страличиваны Москве и новостей в мире - Клуб «Локом Смайлики — Игры в Таможня.ру - играя фабрики Андрей | Флок Devel in Moscow Rust turbo (190) 1997 г.в. Цена для авто №1: автомобилей\",1,\"2013-07-02 07:59:17.000000000\",\"2013-07-02 08:00:00.000000000\",46429,1553640326,115,168449836300271247,0,44,5,\"http://smeshariki.ru/user=googleb18f7700.6384695,926425668_hornolyanovosibirsk.irr.ru/yekategory_id\",\"http://smeshariki.ru/page/Search?text=одинокауты&clid\",0,16000,158,9911,216,1087,938,37,15,7,\"700\",0,0,22,\"nA\",1,1,0,0,\"\",\"\",2247425,-1,0,\"\",0,0,1095,872,794,1372772092,4,0,46077,0,\"windows-1251;charset\",1601,0,0,0,9058901074909920800,\"\",276778963,0,0,0,0,0,\"g\",1372752817,22,2,2,113,19,1816213259,45529,-1,13,\"S0\",\"�\f\",\"\",\"\",0,0,0,0,841,321,0,0,\"\",0,\"\",\"NH\u001c\",0,\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",0,-2923571516118524499,1337795999976243980,0\n",
      "5241207090454501610,1,\"Торт и продам Ford (Форд - IRR.ru (Работа и роды (Clean Almera Money Spear Napa Roomantic (Сцены | квартира, ИЩУ КОГДАНА (страличиваны Москве и новостей в мире - Клуб «Локом Смайлики — Игры в Таможня.ру - играя фабрики Андрей | Флок Devel in Moscow Rust turbo (190) 1997 г.в. Цена для авто №1: автомобилей\",1,\"2013-07-02 09:59:29.000000000\",\"2013-07-02 08:00:00.000000000\",46429,1553640326,115,168449836300271247,0,44,5,\"http://smeshariki.ru/user=googleb18f7700.63870&statuiroveltietsk.irr.ru/search/ab_district=32895080910\",\"http://yandex.ru/ch/world&balcon/germanske.ru/moskovskaya\",0,0,0,9911,216,1087,938,37,15,7,\"700\",0,0,22,\"D�\",1,1,0,0,\"\",\"\",2247425,1,0,\"\",0,0,1095,872,794,1372777525,4,0,46077,0,\"windows-1251;charset\",1601,0,0,0,9058901074909920800,\"\",943360174,0,0,0,0,0,\"5\",1372757844,22,2,2,113,19,1816213259,34235,-1,1,\"�\",\"�\f\",\"\",\"\",0,0,105,348,684,203,12733,0,\"\",0,\"\",\"NH\u001c\",0,\"\",\"\",\"\",\"\",\"feedburner\",\"banner\",\"ad_cpamarketing\",\"\",\"\",\"\",0,4719160989640449379,2196566102793075843,0\n",
      "8762858360217969903,1,\"\",1,\"2013-07-02 09:59:42.000000000\",\"2013-07-02 08:00:00.000000000\",46429,1553640326,115,168449836300271247,0,44,5,\"http://smeshariki.ru/user=googleb18f7700.63870&statuiroveltietsk.irr.ru/search/ab_district=32895080910\",\"\",0,0,0,9911,216,1087,938,37,15,7,\"700\",0,0,22,\"D�\",1,1,0,0,\"\",\"\",2247425,0,0,\"\",0,1,1095,872,794,1372777540,4,0,46077,0,\"windows-1251;charset\",1601,0,0,1,9058901074909920800,\"\",943360174,0,0,0,1,0,\"5\",1372757858,22,2,2,113,19,1816213259,34235,-1,1,\"�\",\"�\f\",\"\",\"\",0,963,0,0,0,0,0,0,\"\",0,\"\",\"NH\u001c\",0,\"\",\"\",\"\",\"\",\"feedburner\",\"banner\",\"ad_cpamarketing\",\"\",\"\",\"\",0,-296158784638538920,2196566102793075843,0\n",
      "5937582489445775385,1,\"прода. Поиск повый бизнес\",1,\"2013-07-02 10:46:42.000000000\",\"2013-07-02 08:00:00.000000000\",63621,-1801466482,229,5639771411007874048,1,44,3,\"http://wildberrior/en-ru/Lingvo/#1.php3?google.ru/mymail.ru/kids\",\"https://go.mail/folders/list.html?cityid=False&rubrics=&location=search?text\",0,14550,952,8953,3,1996,1781,23,15,7,\"700\",0,0,26,\"D�\",1,1,0,0,\"\",\"\",2865462,3,2,\"чесное малософский\",0,0,1261,972,135,1372750201,4,1,16561,0,\"windows-1251;charset\",1,0,0,0,8716223275232676708,\"\",82371000,0,0,0,0,0,\"5\",1372713610,50,1,3,4,22,-1086971547,-1,-1,-1,\"S0\",\"�\f\",\"\",\"\",0,0,0,0,0,0,0,0,\"\",0,\"\",\"NH\u001c\",0,\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",0,532293348752290058,-7069763488219331997,0\n",
      "5585474130921985177,1,\"Торт и продам Ford (Форд - IRR.ru (Работа и роды (Clean Almera Money Spear Napa Roomantic (Сцены | квартира, ИЩУ КОГДАНА (страличиваны Москве и новостей в мире - Клуб «Локом Смайлики — Игры в Таможня.ру - играя фабрики Андрей | Флок Devel in Moscow Rust turbo (190) 1997 г.в. Цена для авто №1: автомобилей\",1,\"2013-07-02 10:50:56.000000000\",\"2013-07-02 08:00:00.000000000\",46429,-1366734181,44,6484173929977037196,0,74,5,\"http://smeshariki.ru/user=googleb18f7700.6384695,926425668_hornolyanovosibirsk.irr.ru/yekategory_id\",\"http://loveplanet.ru/main.aspx?nspn=0.4331/metalliance\",0,16163,952,9911,216,339,777,23,0,0,\"\",0,0,18,\"D�\",1,1,1,0,\"\",\"\",1203796,11,0,\"\",0,0,724,2027,322,1372777472,0,0,0,0,\"windows-1251;charset\",1601,0,0,0,5395316558279634204,\"\",738865320,0,0,0,0,0,\"g\",1372783399,22,2,2,14652,92,-189312298,9866,-1,1,\"S0\",\"h1\",\"\",\"\",0,0,116,204,1657,972,1674,1,\"\",0,\"\",\"NH\u001c\",0,\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",0,-43688538285913943,1337795999976243980,0\n",
      "8119609642256502216,1,\"\",1,\"2013-07-02 10:51:09.000000000\",\"2013-07-02 08:00:00.000000000\",46429,-1366734181,44,6484173929977037196,0,74,5,\"http://smeshariki.ru/user=googleb18f7700.6384695,926425668_hornolyanovosibirsk.irr.ru/yekategory_id\",\"\",0,0,0,9911,216,339,777,23,0,0,\"\",0,0,18,\"D�\",1,1,1,0,\"\",\"\",1203796,0,0,\"\",0,1,724,2027,322,1372777497,0,0,0,0,\"windows-1251;charset\",1601,0,0,1,5395316558279634204,\"\",738865320,0,0,0,1,0,\"5\",1372783413,22,2,2,14652,92,-189312298,9866,-1,1,\"S0\",\"h1\",\"\",\"\",0,2215,0,0,0,0,0,0,\"\",0,\"\",\"NH\u001c\",0,\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",0,-296158784638538920,1337795999976243980,0\n",
      "8851521334882706019,0,\"Вопростовый стал Петербурге. Последников в продажа, центре парфюм\",1,\"2013-07-02 13:18:07.000000000\",\"2013-07-02 08:00:00.000000000\",39641,1897404057,12,2147819122923023112,1,44,3,\"http://domchel.ru/board.php?id=767128787753779.eccord.ru/?trafkey=4300&brand=RAINBOW - bonprix.ru/googleuserId=4&ord=крючком\",\"http://wildberries.ru/invid=19753.html?sort=rating\",0,256,20,426,22,1368,554,23,15,7,\"700\",0,0,17,\"D�\",1,1,0,0,\"\",\"\",3665494,-1,0,\"\",0,0,1863,726,135,1372753287,4,1,16561,0,\"windows-1251;charset\",1,0,0,0,7356234246907529433,\"\",1031476090,0,0,0,0,0,\"5\",1372772961,0,1,0,0,0,1451194443,-1,-1,-1,\"S0\",\"�\f\",\"\",\"\",0,0,0,0,0,0,0,0,\"\",0,\"\",\"NH\u001c\",0,\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",0,6285928018624721980,-6462309590271025210,0\n",
      "\n",
      "Polars time: 0.18419170379638672\n",
      "Polars return:\n",
      " shape: (10, 105)\n",
      "┌────────────┬────────────┬────────────┬───────────┬───┬──────────┬────────────┬────────────┬──────┐\n",
      "│ WatchID    ┆ JavaEnable ┆ Title      ┆ GoodEvent ┆ … ┆ HasGCLID ┆ RefererHas ┆ URLHash    ┆ CLID │\n",
      "│ ---        ┆ ---        ┆ ---        ┆ ---       ┆   ┆ ---      ┆ h          ┆ ---        ┆ ---  │\n",
      "│ i64        ┆ i16        ┆ str        ┆ i16       ┆   ┆ i16      ┆ ---        ┆ i64        ┆ i32  │\n",
      "│            ┆            ┆            ┆           ┆   ┆          ┆ i64        ┆            ┆      │\n",
      "╞════════════╪════════════╪════════════╪═══════════╪═══╪══════════╪════════════╪════════════╪══════╡\n",
      "│ 7106264041 ┆ 1          ┆ ГОСТЕЛЬНОЗ ┆ 1         ┆ … ┆ 0        ┆ -365184249 ┆ 5528743655 ┆ 0    │\n",
      "│ 910208868  ┆            ┆ ЕРОГ       ┆           ┆   ┆          ┆ 7912472547 ┆ 405710480  ┆      │\n",
      "│            ┆            ┆ ГОРНЫЙ     ┆           ┆   ┆          ┆            ┆            ┆      │\n",
      "│            ┆            ┆ ДОЖДЬ! -…  ┆           ┆   ┆          ┆            ┆            ┆      │\n",
      "│ 6801361853 ┆ 1          ┆ Смешарики  ┆ 1         ┆ … ┆ 0        ┆ 5673263859 ┆ -643368365 ┆ 0    │\n",
      "│ 621701142  ┆            ┆ SW |       ┆           ┆   ┆          ┆ 390493714  ┆ 4023857482 ┆      │\n",
      "│            ┆            ┆ SexWife:   ┆           ┆   ┆          ┆            ┆            ┆      │\n",
      "│            ┆            ┆ Женщин…    ┆           ┆   ┆          ┆            ┆            ┆      │\n",
      "│ 7370235307 ┆ 1          ┆            ┆ 1         ┆ … ┆ 0        ┆ -296158784 ┆ -643368365 ┆ 0    │\n",
      "│ 579469118  ┆            ┆            ┆           ┆   ┆          ┆ 638538920  ┆ 4023857482 ┆      │\n",
      "│ 7299686183 ┆ 1          ┆ Торт и     ┆ 1         ┆ … ┆ 0        ┆ -292357151 ┆ 1337795999 ┆ 0    │\n",
      "│ 082339643  ┆            ┆ продам     ┆           ┆   ┆          ┆ 6118524499 ┆ 976243980  ┆      │\n",
      "│            ┆            ┆ Ford (Форд ┆           ┆   ┆          ┆            ┆            ┆      │\n",
      "│            ┆            ┆ - IRR…     ┆           ┆   ┆          ┆            ┆            ┆      │\n",
      "│ 5241207090 ┆ 1          ┆ Торт и     ┆ 1         ┆ … ┆ 0        ┆ 4719160989 ┆ 2196566102 ┆ 0    │\n",
      "│ 454501610  ┆            ┆ продам     ┆           ┆   ┆          ┆ 640449379  ┆ 793075843  ┆      │\n",
      "│            ┆            ┆ Ford (Форд ┆           ┆   ┆          ┆            ┆            ┆      │\n",
      "│            ┆            ┆ - IRR…     ┆           ┆   ┆          ┆            ┆            ┆      │\n",
      "│ 8762858360 ┆ 1          ┆            ┆ 1         ┆ … ┆ 0        ┆ -296158784 ┆ 2196566102 ┆ 0    │\n",
      "│ 217969903  ┆            ┆            ┆           ┆   ┆          ┆ 638538920  ┆ 793075843  ┆      │\n",
      "│ 5937582489 ┆ 1          ┆ прода.     ┆ 1         ┆ … ┆ 0        ┆ 5322933487 ┆ -706976348 ┆ 0    │\n",
      "│ 445775385  ┆            ┆ Поиск      ┆           ┆   ┆          ┆ 52290058   ┆ 8219331997 ┆      │\n",
      "│            ┆            ┆ повый      ┆           ┆   ┆          ┆            ┆            ┆      │\n",
      "│            ┆            ┆ бизнес     ┆           ┆   ┆          ┆            ┆            ┆      │\n",
      "│ 5585474130 ┆ 1          ┆ Торт и     ┆ 1         ┆ … ┆ 0        ┆ -436885382 ┆ 1337795999 ┆ 0    │\n",
      "│ 921985177  ┆            ┆ продам     ┆           ┆   ┆          ┆ 85913943   ┆ 976243980  ┆      │\n",
      "│            ┆            ┆ Ford (Форд ┆           ┆   ┆          ┆            ┆            ┆      │\n",
      "│            ┆            ┆ - IRR…     ┆           ┆   ┆          ┆            ┆            ┆      │\n",
      "│ 8119609642 ┆ 1          ┆            ┆ 1         ┆ … ┆ 0        ┆ -296158784 ┆ 1337795999 ┆ 0    │\n",
      "│ 256502216  ┆            ┆            ┆           ┆   ┆          ┆ 638538920  ┆ 976243980  ┆      │\n",
      "│ 8851521334 ┆ 0          ┆ Вопростовы ┆ 1         ┆ … ┆ 0        ┆ 6285928018 ┆ -646230959 ┆ 0    │\n",
      "│ 882706019  ┆            ┆ й стал Пет ┆           ┆   ┆          ┆ 624721980  ┆ 0271025210 ┆      │\n",
      "│            ┆            ┆ ербурге.   ┆           ┆   ┆          ┆            ┆            ┆      │\n",
      "│            ┆            ┆ П…         ┆           ┆   ┆          ┆            ┆            ┆      │\n",
      "└────────────┴────────────┴────────────┴───────────┴───┴──────────┴────────────┴────────────┴──────┘\n",
      "Q24 SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY EventTime LIMIT 10;\n",
      "Pandas time: 2.3252789974212646\n",
      "Pandas return:\n",
      "                                               SearchPhrase\n",
      "5936205                                ночно китая женщины\n",
      "8064786  маршава нибудь в омске главнованные автобаза ф...\n",
      "8851501                            20 робигудинг для маске\n",
      "8853400                       выкупонорманский рублендодат\n",
      "8828551  комнаталогическая область дней партная вечер э...\n",
      "5290447  кифосов calib.ru/show отзывы июнь 2013 смотрет...\n",
      "222072   безруководительное пирование групп иридиана фл...\n",
      "6023605  орфограмма дачи 1 части заработа в казар кобак...\n",
      "3608548    доктор крем качественна каленко 1 литель заезды\n",
      "8916195                          киа x2-02 mhz/17.3 казань\n",
      "DuckDB time: 0.1318378448486328\n",
      "DuckDB return:\n",
      "                                         SearchPhrase\n",
      "0                                ночно китая женщины\n",
      "1                            20 робигудинг для маске\n",
      "2  маршава нибудь в омске главнованные автобаза ф...\n",
      "3                       выкупонорманский рублендодат\n",
      "4  комнаталогическая область дней партная вечер э...\n",
      "5  кифосов calib.ru/show отзывы июнь 2013 смотрет...\n",
      "6  безруководительное пирование групп иридиана фл...\n",
      "7  орфограмма дачи 1 части заработа в казар кобак...\n",
      "8    доктор крем качественна каленко 1 литель заезды\n",
      "9                          киа x2-02 mhz/17.3 казань\n",
      "chDB time: 0.0423429012298584\n",
      "chDB return:\n",
      " \"ночно китая женщины\"\n",
      "\"маршава нибудь в омске главнованные автобаза физовать\"\n",
      "\"20 робигудинг для маске\"\n",
      "\"выкупонорманский рублендодат\"\n",
      "\"комнаталогическая область дней партная вечер это чудо видео\"\n",
      "\"кифосов calib.ru/show отзывы июнь 2013 смотреть онлайн\"\n",
      "\"безруководительное пирование групп иридиана флешмоб\"\n",
      "\"доктор крем качественна каленко 1 литель заезды\"\n",
      "\"орфограмма дачи 1 части заработа в казар кобакал по гал поль+стели пожар\"\n",
      "\"киа x2-02 mhz/17.3 казань\"\n",
      "\n",
      "Polars time: 0.27924275398254395\n",
      "Polars return:\n",
      " shape: (10, 1)\n",
      "┌─────────────────────────────────┐\n",
      "│ SearchPhrase                    │\n",
      "│ ---                             │\n",
      "│ str                             │\n",
      "╞═════════════════════════════════╡\n",
      "│ ночно китая женщины             │\n",
      "│ маршава нибудь в омске главнов… │\n",
      "│ 20 робигудинг для маске         │\n",
      "│ выкупонорманский рублендодат    │\n",
      "│ комнаталогическая область дней… │\n",
      "│ кифосов calib.ru/show отзывы и… │\n",
      "│ безруководительное пирование г… │\n",
      "│ доктор крем качественна каленк… │\n",
      "│ орфограмма дачи 1 части зарабо… │\n",
      "│ киа x2-02 mhz/17.3 казань       │\n",
      "└─────────────────────────────────┘\n",
      "Q25 SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY SearchPhrase LIMIT 10;\n",
      "Pandas time: 3.9367663860321045\n",
      "Pandas return:\n",
      "                                    SearchPhrase\n",
      "8581793                                    прав\n",
      "3506663                    светы женске 2 сезон\n",
      "3400727  !куги для мясорубкина зимняя из виолет\n",
      "9472812              $_get am2 купейн в хорошем\n",
      "7982167           $_get it of goodbye minecraft\n",
      "3842151                   $_get_series v stell \n",
      "1859999        $_poslandon.ru/moscow 2 торговлю\n",
      "7981418                              $d причина\n",
      "1467180                                % стасия\n",
      "5058192     &#1092 купить шарарасота в турбации\n",
      "DuckDB time: 0.2535984516143799\n",
      "DuckDB return:\n",
      "                              SearchPhrase\n",
      "0                                    прав\n",
      "1                    светы женске 2 сезон\n",
      "2  !куги для мясорубкина зимняя из виолет\n",
      "3              $_get am2 купейн в хорошем\n",
      "4           $_get it of goodbye minecraft\n",
      "5                   $_get_series v stell \n",
      "6        $_poslandon.ru/moscow 2 торговлю\n",
      "7                              $d причина\n",
      "8                                % стасия\n",
      "9     &#1092 купить шарарасота в турбации\n",
      "chDB time: 0.03441929817199707\n",
      "chDB return:\n",
      " \" прав\"\n",
      "\" светы женске 2 сезон\"\n",
      "\"!куги для мясорубкина зимняя из виолет\"\n",
      "\"$_get am2 купейн в хорошем\"\n",
      "\"$_get it of goodbye minecraft\"\n",
      "\"$_get_series v stell \"\n",
      "\"$_poslandon.ru/moscow 2 торговлю\"\n",
      "\"$d причина\"\n",
      "\"% стасия\"\n",
      "\"&#1092 купить шарарасота в турбации\"\n",
      "\n",
      "Polars time: 0.2817411422729492\n",
      "Polars return:\n",
      " shape: (10, 1)\n",
      "┌─────────────────────────────────┐\n",
      "│ SearchPhrase                    │\n",
      "│ ---                             │\n",
      "│ str                             │\n",
      "╞═════════════════════════════════╡\n",
      "│  прав                           │\n",
      "│  светы женске 2 сезон           │\n",
      "│ !куги для мясорубкина зимняя и… │\n",
      "│ $_get am2 купейн в хорошем      │\n",
      "│ $_get it of goodbye minecraft   │\n",
      "│ $_get_series v stell            │\n",
      "│ $_poslandon.ru/moscow 2 торгов… │\n",
      "│ $d причина                      │\n",
      "│ % стасия                        │\n",
      "│ &#1092 купить шарарасота в тур… │\n",
      "└─────────────────────────────────┘\n",
      "Q26 SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY EventTime, SearchPhrase LIMIT 10;\n",
      "Pandas time: 4.12407112121582\n",
      "Pandas return:\n",
      "                                               SearchPhrase\n",
      "5936205                                ночно китая женщины\n",
      "8851501                            20 робигудинг для маске\n",
      "8064786  маршава нибудь в омске главнованные автобаза ф...\n",
      "8853400                       выкупонорманский рублендодат\n",
      "8828551  комнаталогическая область дней партная вечер э...\n",
      "5290447  кифосов calib.ru/show отзывы июнь 2013 смотрет...\n",
      "222072   безруководительное пирование групп иридиана фл...\n",
      "3608548    доктор крем качественна каленко 1 литель заезды\n",
      "6023605  орфограмма дачи 1 части заработа в казар кобак...\n",
      "8916195                          киа x2-02 mhz/17.3 казань\n",
      "DuckDB time: 0.18941974639892578\n",
      "DuckDB return:\n",
      "                                         SearchPhrase\n",
      "0                                ночно китая женщины\n",
      "1                            20 робигудинг для маске\n",
      "2  маршава нибудь в омске главнованные автобаза ф...\n",
      "3                       выкупонорманский рублендодат\n",
      "4  комнаталогическая область дней партная вечер э...\n",
      "5  кифосов calib.ru/show отзывы июнь 2013 смотрет...\n",
      "6  безруководительное пирование групп иридиана фл...\n",
      "7    доктор крем качественна каленко 1 литель заезды\n",
      "8  орфограмма дачи 1 части заработа в казар кобак...\n",
      "9                          киа x2-02 mhz/17.3 казань\n",
      "chDB time: 0.046121835708618164\n",
      "chDB return:\n",
      " \"ночно китая женщины\"\n",
      "\"20 робигудинг для маске\"\n",
      "\"маршава нибудь в омске главнованные автобаза физовать\"\n",
      "\"выкупонорманский рублендодат\"\n",
      "\"комнаталогическая область дней партная вечер это чудо видео\"\n",
      "\"кифосов calib.ru/show отзывы июнь 2013 смотреть онлайн\"\n",
      "\"безруководительное пирование групп иридиана флешмоб\"\n",
      "\"доктор крем качественна каленко 1 литель заезды\"\n",
      "\"орфограмма дачи 1 части заработа в казар кобакал по гал поль+стели пожар\"\n",
      "\"киа x2-02 mhz/17.3 казань\"\n",
      "\n",
      "Polars time: 0.2635948657989502\n",
      "Polars return:\n",
      " shape: (10, 1)\n",
      "┌─────────────────────────────────┐\n",
      "│ SearchPhrase                    │\n",
      "│ ---                             │\n",
      "│ str                             │\n",
      "╞═════════════════════════════════╡\n",
      "│ ночно китая женщины             │\n",
      "│ 20 робигудинг для маске         │\n",
      "│ маршава нибудь в омске главнов… │\n",
      "│ выкупонорманский рублендодат    │\n",
      "│ комнаталогическая область дней… │\n",
      "│ кифосов calib.ru/show отзывы и… │\n",
      "│ безруководительное пирование г… │\n",
      "│ доктор крем качественна каленк… │\n",
      "│ орфограмма дачи 1 части зарабо… │\n",
      "│ киа x2-02 mhz/17.3 казань       │\n",
      "└─────────────────────────────────┘\n",
      "Q27 SELECT CounterID, AVG(STRLEN(URL)) AS l, COUNT(*) AS c FROM hits WHERE URL <> '' GROUP BY CounterID HAVING COUNT(*) > 100000 ORDER BY l DESC LIMIT 25;\n",
      "Pandas time: 11.973230361938477\n",
      "Pandas return:\n",
      " URL          8.830068e+01\n",
      "CounterID    6.427221e+06\n",
      "dtype: float64\n",
      "DuckDB time: 0.1553800106048584\n",
      "DuckDB return:\n",
      "     CounterID           l       c\n",
      "0      122612  240.497421  638968\n",
      "1        1634  194.214108  118954\n",
      "2      199550  110.135978  868030\n",
      "3          62   91.785075  106493\n",
      "4        3922   87.610597  924581\n",
      "5      146891   83.673486  103873\n",
      "6          38   76.566724  163720\n",
      "7        1483   71.329880  254380\n",
      "8       46429   70.677078  474517\n",
      "9      117917   69.057769  106389\n",
      "10       2264   67.726046  106496\n",
      "11      95978   66.667985  106459\n",
      "12       5822   63.244084  106496\n",
      "13      56820   61.759401  141825\n",
      "14      76325   61.406250  106496\n",
      "15     145496   59.204685  212991\n",
      "16       7525   57.203026  166447\n",
      "17     119677   56.938542  212992\n",
      "18     178321   54.154552  196600\n",
      "19     128858   52.101964  182613\n",
      "20      99062   50.314067  248574\n",
      "21     140443   45.106507  158469\n",
      "22     105857   40.067755  501707\n",
      "23      69154   37.375145  112655\n",
      "24      63217   34.884080  106496\n",
      "chDB time: 0.14062786102294922\n",
      "chDB return:\n",
      " 122612,240.49742084110628,638968\n",
      "1634,194.21410797451117,118954\n",
      "199550,110.13597801919289,868030\n",
      "62,91.78507507535707,106493\n",
      "3922,87.61059658374982,924581\n",
      "146891,83.6734858914251,103873\n",
      "38,76.56672367456633,163720\n",
      "1483,71.32988049374951,254380\n",
      "46429,70.67707795505746,474517\n",
      "117917,69.05776913026723,106389\n",
      "2264,67.72604604867789,106496\n",
      "95978,66.66798485802046,106459\n",
      "5822,63.24408428485577,106496\n",
      "56820,61.75940066983959,141825\n",
      "76325,61.40625,106496\n",
      "145496,59.204684704987535,212991\n",
      "7525,57.20302558772462,166447\n",
      "119677,56.93854229266827,212992\n",
      "178321,54.154552390640895,196600\n",
      "128858,52.101964263223316,182613\n",
      "99062,50.31406744068165,248574\n",
      "140443,45.10650663536717,158469\n",
      "105857,40.067754685503694,501707\n",
      "69154,37.37514535528827,112655\n",
      "63217,34.88408015324519,106496\n",
      "\n",
      "Polars time: 0.8907685279846191\n",
      "Polars return:\n",
      " shape: (25, 3)\n",
      "┌───────────┬────────┬────────┐\n",
      "│ CounterID ┆ l      ┆ c      │\n",
      "│ ---       ┆ ---    ┆ ---    │\n",
      "│ i32       ┆ i64    ┆ u32    │\n",
      "╞═══════════╪════════╪════════╡\n",
      "│ 3922      ┆ 924581 ┆ 924581 │\n",
      "│ 199550    ┆ 868030 ┆ 868030 │\n",
      "│ 122612    ┆ 638968 ┆ 638968 │\n",
      "│ 105857    ┆ 501707 ┆ 501707 │\n",
      "│ 46429     ┆ 474517 ┆ 474517 │\n",
      "│ …         ┆ …      ┆ …      │\n",
      "│ 76325     ┆ 106496 ┆ 106496 │\n",
      "│ 62        ┆ 106493 ┆ 106493 │\n",
      "│ 95978     ┆ 106459 ┆ 106459 │\n",
      "│ 117917    ┆ 106389 ┆ 106389 │\n",
      "│ 146891    ┆ 103873 ┆ 103873 │\n",
      "└───────────┴────────┴────────┘\n",
      "Q28 SELECT REGEXP_REPLACE(Referer, '^https?://(?:www\\.)?([^/]+)/.*$', '\\1') AS k, AVG(STRLEN(Referer)) AS l, COUNT(*) AS c, MIN(Referer) FROM hits WHERE Referer <> '' GROUP BY k HAVING COUNT(*) > 100000 ORDER BY l DESC LIMIT 25;\n",
      "Pandas time: 30.965622425079346\n",
      "Pandas return:\n",
      "                             Referer\n",
      "min_referer     http://auto.ria.ua/\n",
      "average_length            74.443681\n",
      "DuckDB time: 0.5170934200286865\n",
      "DuckDB return:\n",
      "                       k           l       c  \\\n",
      "0             google.ru  115.428171  248632   \n",
      "1               go.mail  108.236910  943831   \n",
      "2             mysw.info   91.010802  101187   \n",
      "3             yandex.ru   70.708391  539043   \n",
      "4       video.yandex.ru   69.446100  111587   \n",
      "5        wildberries.ru   68.842407  144442   \n",
      "6           auto.ria.ua   62.589863  132368   \n",
      "7         smeshariki.ru   58.874002  517890   \n",
      "8                irr.ru   54.573039  176522   \n",
      "9         bdsmpeople.ru   53.188323  207351   \n",
      "10           google.com   38.552378  327560   \n",
      "11  http:%2F%2Fwwww.ukr   19.000000  118140   \n",
      "\n",
      "                                         min(Referer)  \n",
      "0                                   http://google.ru/  \n",
      "1   http://go.mail/?ID=26175503771357/pic/8437/1/c...  \n",
      "2                                   http://mysw.info/  \n",
      "3                                   http://yandex.ru/  \n",
      "4    http://video.yandex.ru//emilka%2Firr.ru/regionId  \n",
      "5                              http://wildberries.ru/  \n",
      "6                                 http://auto.ria.ua/  \n",
      "7                               http://smeshariki.ru/  \n",
      "8   http://irr.ru/121838478&text=профнастя картира...  \n",
      "9                               http://bdsmpeople.ru/  \n",
      "10                      http://google.com/&http://ria  \n",
      "11                                http:%2F%2Fwwww.ukr  \n",
      "chDB time: 0.2968788146972656\n",
      "chDB return:\n",
      " \"google.ru\",115.42817095144632,248632,\"http://google.ru/\"\n",
      "\"go.mail\",108.23690999765847,943831,\"http://go.mail/?ID=26175503771357/pic/8437/1/courtner-pub-61589792\"\n",
      "\"mysw.info\",91.01080178283772,101187,\"http://mysw.info/\"\n",
      "\"yandex.ru\",70.7083906107676,539043,\"http://yandex.ru/\"\n",
      "\"video.yandex.ru\",69.44610035219156,111587,\"http://video.yandex.ru//emilka%2Firr.ru/regionId\"\n",
      "\"wildberries.ru\",68.84240733304718,144442,\"http://wildberries.ru/\"\n",
      "\"auto.ria.ua\",62.589863108908496,132368,\"http://auto.ria.ua/\"\n",
      "\"smeshariki.ru\",58.87400220123965,517890,\"http://smeshariki.ru/\"\n",
      "\"irr.ru\",54.573039054622086,176522,\"http://irr.ru/121838478&text=профнастя картиральский&source=android\"\n",
      "\"bdsmpeople.ru\",53.18832318146524,207351,\"http://bdsmpeople.ru/\"\n",
      "\"google.com\",38.55237819025522,327560,\"http://google.com/&http://ria\"\n",
      "\"http:%2F%2Fwwww.ukr\",19,118140,\"http:%2F%2Fwwww.ukr\"\n",
      "\n",
      "Polars time: 6.252786636352539\n",
      "Polars return:\n",
      " shape: (12, 4)\n",
      "┌─────────────────┬─────────┬─────────────────────────────────┬─────────┐\n",
      "│ k               ┆ l       ┆ min_referer                     ┆ c       │\n",
      "│ ---             ┆ ---     ┆ ---                             ┆ ---     │\n",
      "│ str             ┆ i64     ┆ str                             ┆ u32     │\n",
      "╞═════════════════╪═════════╪═════════════════════════════════╪═════════╡\n",
      "│ null            ┆ 1802377 ┆ http:%2F%23id:14967.htm%3Fhash… ┆ 1802377 │\n",
      "│ go.mail         ┆ 943831  ┆ http://go.mail/?ID=26175503771… ┆ 943831  │\n",
      "│ yandex.ru       ┆ 539043  ┆ http://yandex.ru/               ┆ 539043  │\n",
      "│ smeshariki.ru   ┆ 517890  ┆ http://smeshariki.ru/           ┆ 517890  │\n",
      "│ google.com      ┆ 327560  ┆ http://google.com/&http://ria   ┆ 327560  │\n",
      "│ …               ┆ …       ┆ …                               ┆ …       │\n",
      "│ irr.ru          ┆ 176522  ┆ http://irr.ru/121838478&text=п… ┆ 176522  │\n",
      "│ wildberries.ru  ┆ 144420  ┆ http://wildberries.ru/          ┆ 144420  │\n",
      "│ auto.ria.ua     ┆ 132368  ┆ http://auto.ria.ua/             ┆ 132368  │\n",
      "│ video.yandex.ru ┆ 111587  ┆ http://video.yandex.ru//emilka… ┆ 111587  │\n",
      "│ mysw.info       ┆ 101187  ┆ http://mysw.info/               ┆ 101187  │\n",
      "└─────────────────┴─────────┴─────────────────────────────────┴─────────┘\n",
      "Q29 SELECT SUM(ResolutionWidth), SUM(ResolutionWidth + 1), SUM(ResolutionWidth + 2), SUM(ResolutionWidth + 3), SUM(ResolutionWidth + 4), SUM(ResolutionWidth + 5), SUM(ResolutionWidth + 6), SUM(ResolutionWidth + 7), SUM(ResolutionWidth + 8), SUM(ResolutionWidth + 9), SUM(ResolutionWidth + 10), SUM(ResolutionWidth + 11), SUM(ResolutionWidth + 12), SUM(ResolutionWidth + 13), SUM(ResolutionWidth + 14), SUM(ResolutionWidth + 15), SUM(ResolutionWidth + 16), SUM(ResolutionWidth + 17), SUM(ResolutionWidth + 18), SUM(ResolutionWidth + 19), SUM(ResolutionWidth + 20), SUM(ResolutionWidth + 21), SUM(ResolutionWidth + 22), SUM(ResolutionWidth + 23), SUM(ResolutionWidth + 24), SUM(ResolutionWidth + 25), SUM(ResolutionWidth + 26), SUM(ResolutionWidth + 27), SUM(ResolutionWidth + 28), SUM(ResolutionWidth + 29), SUM(ResolutionWidth + 30), SUM(ResolutionWidth + 31), SUM(ResolutionWidth + 32), SUM(ResolutionWidth + 33), SUM(ResolutionWidth + 34), SUM(ResolutionWidth + 35), SUM(ResolutionWidth + 36), SUM(ResolutionWidth + 37), SUM(ResolutionWidth + 38), SUM(ResolutionWidth + 39), SUM(ResolutionWidth + 40), SUM(ResolutionWidth + 41), SUM(ResolutionWidth + 42), SUM(ResolutionWidth + 43), SUM(ResolutionWidth + 44), SUM(ResolutionWidth + 45), SUM(ResolutionWidth + 46), SUM(ResolutionWidth + 47), SUM(ResolutionWidth + 48), SUM(ResolutionWidth + 49), SUM(ResolutionWidth + 50), SUM(ResolutionWidth + 51), SUM(ResolutionWidth + 52), SUM(ResolutionWidth + 53), SUM(ResolutionWidth + 54), SUM(ResolutionWidth + 55), SUM(ResolutionWidth + 56), SUM(ResolutionWidth + 57), SUM(ResolutionWidth + 58), SUM(ResolutionWidth + 59), SUM(ResolutionWidth + 60), SUM(ResolutionWidth + 61), SUM(ResolutionWidth + 62), SUM(ResolutionWidth + 63), SUM(ResolutionWidth + 64), SUM(ResolutionWidth + 65), SUM(ResolutionWidth + 66), SUM(ResolutionWidth + 67), SUM(ResolutionWidth + 68), SUM(ResolutionWidth + 69), SUM(ResolutionWidth + 70), SUM(ResolutionWidth + 71), SUM(ResolutionWidth + 72), SUM(ResolutionWidth + 73), SUM(ResolutionWidth + 74), SUM(ResolutionWidth + 75), SUM(ResolutionWidth + 76), SUM(ResolutionWidth + 77), SUM(ResolutionWidth + 78), SUM(ResolutionWidth + 79), SUM(ResolutionWidth + 80), SUM(ResolutionWidth + 81), SUM(ResolutionWidth + 82), SUM(ResolutionWidth + 83), SUM(ResolutionWidth + 84), SUM(ResolutionWidth + 85), SUM(ResolutionWidth + 86), SUM(ResolutionWidth + 87), SUM(ResolutionWidth + 88), SUM(ResolutionWidth + 89) FROM hits;\n",
      "Pandas time: 2.758824586868286\n",
      "Pandas return:\n",
      " 1356994681947.0\n",
      "DuckDB time: 0.20304656028747559\n",
      "DuckDB return:\n",
      "    sum(ResolutionWidth)  sum((ResolutionWidth + 1))  \\\n",
      "0          1.507779e+10                1.508779e+10   \n",
      "\n",
      "   sum((ResolutionWidth + 2))  sum((ResolutionWidth + 3))  \\\n",
      "0                1.509779e+10                1.510779e+10   \n",
      "\n",
      "   sum((ResolutionWidth + 4))  sum((ResolutionWidth + 5))  \\\n",
      "0                1.511779e+10                1.512779e+10   \n",
      "\n",
      "   sum((ResolutionWidth + 6))  sum((ResolutionWidth + 7))  \\\n",
      "0                1.513779e+10                1.514779e+10   \n",
      "\n",
      "   sum((ResolutionWidth + 8))  sum((ResolutionWidth + 9))  ...  \\\n",
      "0                1.515779e+10                1.516779e+10  ...   \n",
      "\n",
      "   sum((ResolutionWidth + 80))  sum((ResolutionWidth + 81))  \\\n",
      "0                 1.587779e+10                 1.588779e+10   \n",
      "\n",
      "   sum((ResolutionWidth + 82))  sum((ResolutionWidth + 83))  \\\n",
      "0                 1.589779e+10                 1.590779e+10   \n",
      "\n",
      "   sum((ResolutionWidth + 84))  sum((ResolutionWidth + 85))  \\\n",
      "0                 1.591779e+10                 1.592779e+10   \n",
      "\n",
      "   sum((ResolutionWidth + 86))  sum((ResolutionWidth + 87))  \\\n",
      "0                 1.593779e+10                 1.594779e+10   \n",
      "\n",
      "   sum((ResolutionWidth + 88))  sum((ResolutionWidth + 89))  \n",
      "0                 1.595779e+10                 1.596779e+10  \n",
      "\n",
      "[1 rows x 90 columns]\n",
      "chDB time: 0.05274057388305664\n",
      "chDB return:\n",
      " 15077792377,15087792377,15097792377,15107792377,15117792377,15127792377,15137792377,15147792377,15157792377,15167792377,15177792377,15187792377,15197792377,15207792377,15217792377,15227792377,15237792377,15247792377,15257792377,15267792377,15277792377,15287792377,15297792377,15307792377,15317792377,15327792377,15337792377,15347792377,15357792377,15367792377,15377792377,15387792377,15397792377,15407792377,15417792377,15427792377,15437792377,15447792377,15457792377,15467792377,15477792377,15487792377,15497792377,15507792377,15517792377,15527792377,15537792377,15547792377,15557792377,15567792377,15577792377,15587792377,15597792377,15607792377,15617792377,15627792377,15637792377,15647792377,15657792377,15667792377,15677792377,15687792377,15697792377,15707792377,15717792377,15727792377,15737792377,15747792377,15757792377,15767792377,15777792377,15787792377,15797792377,15807792377,15817792377,15827792377,15837792377,15847792377,15857792377,15867792377,15877792377,15887792377,15897792377,15907792377,15917792377,15927792377,15937792377,15947792377,15957792377,15967792377\n",
      "\n",
      "Polars time: 0.0001652240753173828\n",
      "Polars return:\n",
      " 141195\n",
      "Q30 SELECT SearchEngineID, ClientIP, COUNT(*) AS c, SUM(IsRefresh), AVG(ResolutionWidth) FROM hits WHERE SearchPhrase <> '' GROUP BY SearchEngineID, ClientIP ORDER BY c DESC LIMIT 10;\n",
      "Pandas time: 1.535578966140747\n",
      "Pandas return:\n",
      "                               c  IsRefreshSum  AvgResolutionWidth\n",
      "SearchEngineID ClientIP                                          \n",
      "2               1138507705  167             2         1383.610778\n",
      "                1740861572  167             0         1601.982036\n",
      "               -1106675868  158             2         1507.170886\n",
      "                1124827693  155            77         1749.277419\n",
      "               -497906719   152             1         1534.506579\n",
      "               -631062503   140             8         1557.242857\n",
      "                1146197031  139             6         1598.287770\n",
      "               -1870623097  133             4         1531.691729\n",
      "               -265917476   133             6         1555.090226\n",
      "               -1089778290  132             1         1538.712121\n",
      "DuckDB time: 0.08614468574523926\n",
      "DuckDB return:\n",
      "    SearchEngineID    ClientIP    c  sum(IsRefresh)  avg(ResolutionWidth)\n",
      "0               2  1138507705  167             2.0           1383.610778\n",
      "1               2  1740861572  167             0.0           1601.982036\n",
      "2               2 -1106675868  158             2.0           1507.170886\n",
      "3               2  1124827693  155            77.0           1749.277419\n",
      "4               2  -497906719  152             1.0           1534.506579\n",
      "5               2  -631062503  140             8.0           1557.242857\n",
      "6               2  1146197031  139             6.0           1598.287770\n",
      "7               2 -1870623097  133             4.0           1531.691729\n",
      "8               2  -265917476  133             6.0           1555.090226\n",
      "9               2 -1089778290  132             1.0           1538.712121\n",
      "chDB time: 0.06468677520751953\n",
      "chDB return:\n",
      " 2,1740861572,167,0,1601.9820359281437\n",
      "2,1138507705,167,2,1383.6107784431138\n",
      "2,-1106675868,158,2,1507.1708860759493\n",
      "2,1124827693,155,77,1749.2774193548387\n",
      "2,-497906719,152,1,1534.5065789473683\n",
      "2,-631062503,140,8,1557.2428571428572\n",
      "2,1146197031,139,6,1598.2877697841727\n",
      "2,-265917476,133,6,1555.0902255639098\n",
      "2,-1870623097,133,4,1531.6917293233082\n",
      "2,-1089778290,132,1,1538.7121212121212\n",
      "\n",
      "Polars time: 0.24605369567871094\n",
      "Polars return:\n",
      " shape: (10, 5)\n",
      "┌────────────────┬─────────────┬─────┬──────────────┬────────────────────┐\n",
      "│ SearchEngineID ┆ ClientIP    ┆ c   ┆ IsRefreshSum ┆ AvgResolutionWidth │\n",
      "│ ---            ┆ ---         ┆ --- ┆ ---          ┆ ---                │\n",
      "│ i16            ┆ i32         ┆ u32 ┆ i64          ┆ f64                │\n",
      "╞════════════════╪═════════════╪═════╪══════════════╪════════════════════╡\n",
      "│ 2              ┆ 1740861572  ┆ 167 ┆ 0            ┆ 1601.982036        │\n",
      "│ 2              ┆ 1138507705  ┆ 167 ┆ 2            ┆ 1383.610778        │\n",
      "│ 2              ┆ -1106675868 ┆ 158 ┆ 2            ┆ 1507.170886        │\n",
      "│ 2              ┆ 1124827693  ┆ 155 ┆ 77           ┆ 1749.277419        │\n",
      "│ 2              ┆ -497906719  ┆ 152 ┆ 1            ┆ 1534.506579        │\n",
      "│ 2              ┆ -631062503  ┆ 140 ┆ 8            ┆ 1557.242857        │\n",
      "│ 2              ┆ 1146197031  ┆ 139 ┆ 6            ┆ 1598.28777         │\n",
      "│ 2              ┆ -1870623097 ┆ 133 ┆ 4            ┆ 1531.691729        │\n",
      "│ 2              ┆ -265917476  ┆ 133 ┆ 6            ┆ 1555.090226        │\n",
      "│ 2              ┆ -1089778290 ┆ 132 ┆ 1            ┆ 1538.712121        │\n",
      "└────────────────┴─────────────┴─────┴──────────────┴────────────────────┘\n",
      "Q31 SELECT WatchID, ClientIP, COUNT(*) AS c, SUM(IsRefresh), AVG(ResolutionWidth) FROM hits WHERE SearchPhrase <> '' GROUP BY WatchID, ClientIP ORDER BY c DESC LIMIT 10;\n",
      "Pandas time: 1.996917963027954\n",
      "Pandas return:\n",
      "                                  c  IsRefreshSum  AvgResolutionWidth\n",
      "WatchID             ClientIP                                        \n",
      "4611694259862308721  1939762170  1             0              1368.0\n",
      "4611696918332634655  1745457477  1             0              1996.0\n",
      "4611702827673367990 -866198808   1             0              1368.0\n",
      "4611704896271697334  1145084146  1             0              1368.0\n",
      "4611709901969491340  925192082   1             0              1990.0\n",
      "4611715517272605081  1873681563  1             1              1368.0\n",
      "4611715716176606289  550681580   1             0              1996.0\n",
      "4611715740922561616 -339684538   1             0              1087.0\n",
      "4611717928870807772  1799799829  1             0              1917.0\n",
      "4611720317321800760  659762682   1             0              1087.0\n",
      "DuckDB time: 0.10591721534729004\n",
      "DuckDB return:\n",
      "                WatchID    ClientIP  c  sum(IsRefresh)  avg(ResolutionWidth)\n",
      "0  6818582411365665958   660315215  1             0.0                1368.0\n",
      "1  8791819270435807490  1473828557  1             0.0                1638.0\n",
      "2  7890989371291307084 -1238271973  1             0.0                1996.0\n",
      "3  4924171746038591134  1009621405  1             0.0                1368.0\n",
      "4  7973320409482814316  -643969386  1             0.0                1471.0\n",
      "5  4828359945228318410 -1560671451  1             0.0                1368.0\n",
      "6  7478606104903083014  1439503871  1             0.0                1368.0\n",
      "7  8722491948504705058  1303595993  1             0.0                 582.0\n",
      "8  5662656757024973392  1315069729  1             0.0                1996.0\n",
      "9  6139424863805621355  1526066212  1             0.0                 508.0\n",
      "chDB time: 0.09296727180480957\n",
      "chDB return:\n",
      " 5055679980591148335,-247495422,1,0,1917\n",
      "5268572242740516149,-2084875520,1,0,1638\n",
      "7972036787597603422,1392047940,1,0,1750\n",
      "5901073908092331412,1976973896,1,0,1368\n",
      "7227951727328737869,1767461008,1,0,1638\n",
      "6081390183502573534,911172261,1,0,1638\n",
      "5053868840694598172,1338505058,1,0,184\n",
      "8815896716189863724,513446242,1,0,1996\n",
      "7729270990481304965,-2113508332,1,0,1638\n",
      "8678109688701084511,756024604,1,0,1638\n",
      "\n",
      "Polars time: 0.2792203426361084\n",
      "Polars return:\n",
      " shape: (10, 5)\n",
      "┌─────────────────────┬─────────────┬─────┬──────────────┬────────────────────┐\n",
      "│ WatchID             ┆ ClientIP    ┆ c   ┆ IsRefreshSum ┆ AvgResolutionWidth │\n",
      "│ ---                 ┆ ---         ┆ --- ┆ ---          ┆ ---                │\n",
      "│ i64                 ┆ i32         ┆ u32 ┆ i64          ┆ f64                │\n",
      "╞═════════════════════╪═════════════╪═════╪══════════════╪════════════════════╡\n",
      "│ 8460219899915854782 ┆ 1889832869  ┆ 1   ┆ 0            ┆ 1368.0             │\n",
      "│ 4774246863364486494 ┆ 1677013099  ┆ 1   ┆ 0            ┆ 1996.0             │\n",
      "│ 6191226534489978120 ┆ 1610203158  ┆ 1   ┆ 0            ┆ 1638.0             │\n",
      "│ 8312808744143954042 ┆ 1664566209  ┆ 1   ┆ 1            ┆ 1638.0             │\n",
      "│ 6813864744225277860 ┆ -1172240730 ┆ 1   ┆ 0            ┆ 582.0              │\n",
      "│ 7962310428745386102 ┆ 917216780   ┆ 1   ┆ 0            ┆ 1917.0             │\n",
      "│ 8355656868011943840 ┆ -902402098  ┆ 1   ┆ 0            ┆ 1638.0             │\n",
      "│ 6445042513551559459 ┆ -1529360067 ┆ 1   ┆ 0            ┆ 1917.0             │\n",
      "│ 8975633444743392647 ┆ 1669869597  ┆ 1   ┆ 0            ┆ 1368.0             │\n",
      "│ 8864743372993907341 ┆ 1199394979  ┆ 1   ┆ 0            ┆ 1638.0             │\n",
      "└─────────────────────┴─────────────┴─────┴──────────────┴────────────────────┘\n",
      "Q32 SELECT WatchID, ClientIP, COUNT(*) AS c, SUM(IsRefresh), AVG(ResolutionWidth) FROM hits GROUP BY WatchID, ClientIP ORDER BY c DESC LIMIT 10;\n",
      "Pandas time: 7.862155199050903\n",
      "Pandas return:\n",
      "                                  c  IsRefreshSum  AvgResolutionWidth\n",
      "WatchID             ClientIP                                        \n",
      "6655575552203051303  1611957945  2             0              1638.0\n",
      "7224410078130478461 -776509581   2             0              1368.0\n",
      "4611686363500364104  1221513398  1             0              1990.0\n",
      "4611686402113265154 -1339197305  1             0              1750.0\n",
      "4611686851060971175 -985812753   1             0              1368.0\n",
      "4611687435907085604  1760738510  1             0              1368.0\n",
      "4611687575936721977  1770854750  1             0              1638.0\n",
      "4611687987885605089  1362499323  1             1              1917.0\n",
      "4611688643422516557  2089610172  1             0              1368.0\n",
      "4611688965700267127  564621555   1             0              1087.0\n",
      "DuckDB time: 0.20980262756347656\n",
      "DuckDB return:\n",
      "                WatchID    ClientIP  c  sum(IsRefresh)  avg(ResolutionWidth)\n",
      "0  7224410078130478461  -776509581  2             0.0                1368.0\n",
      "1  6655575552203051303  1611957945  2             0.0                1638.0\n",
      "2  5627139650043745980 -1487414388  1             1.0                1828.0\n",
      "3  8322353452734212386 -1031601240  1             0.0                1087.0\n",
      "4  7456736512784606779 -1031601240  1             0.0                1087.0\n",
      "5  5592741995199699900 -1990988318  1             1.0                1996.0\n",
      "6  7580754668976847738 -1990988318  1             0.0                1996.0\n",
      "7  5747877532050934590 -1990988318  1             1.0                1996.0\n",
      "8  7488286597677165751 -1990988318  1             0.0                1996.0\n",
      "9  4709156312375759729 -1990988318  1             1.0                1996.0\n",
      "chDB time: 0.20761418342590332\n",
      "chDB return:\n",
      " 7224410078130478461,-776509581,2,0,1368\n",
      "6655575552203051303,1611957945,2,0,1638\n",
      "5955546249209499743,87234006,1,0,1917\n",
      "4870754219296985793,1945780190,1,0,1996\n",
      "5851412430027698534,-814720616,1,0,1638\n",
      "6592283700365342656,1975295783,1,0,1368\n",
      "4784329916471068512,-818518996,1,0,1368\n",
      "8978214656603001718,1685764391,1,0,1917\n",
      "7812846363567359668,1659478732,1,0,508\n",
      "6700068120218951102,788087753,1,0,1996\n",
      "\n",
      "Polars time: 0.5795397758483887\n",
      "Polars return:\n",
      " shape: (10, 5)\n",
      "┌─────────────────────┬─────────────┬─────┬──────────────┬────────────────────┐\n",
      "│ WatchID             ┆ ClientIP    ┆ c   ┆ IsRefreshSum ┆ AvgResolutionWidth │\n",
      "│ ---                 ┆ ---         ┆ --- ┆ ---          ┆ ---                │\n",
      "│ i64                 ┆ i32         ┆ u32 ┆ i64          ┆ f64                │\n",
      "╞═════════════════════╪═════════════╪═════╪══════════════╪════════════════════╡\n",
      "│ 6655575552203051303 ┆ 1611957945  ┆ 2   ┆ 0            ┆ 1638.0             │\n",
      "│ 7224410078130478461 ┆ -776509581  ┆ 2   ┆ 0            ┆ 1368.0             │\n",
      "│ 6461300558573284255 ┆ -862970696  ┆ 1   ┆ 0            ┆ 1917.0             │\n",
      "│ 8583375600809868473 ┆ 864819352   ┆ 1   ┆ 0            ┆ 1638.0             │\n",
      "│ 5553133204352700174 ┆ 1902209793  ┆ 1   ┆ 0            ┆ 1250.0             │\n",
      "│ 9071624092466570549 ┆ 1394440351  ┆ 1   ┆ 0            ┆ 582.0              │\n",
      "│ 6137278582682151328 ┆ 1558448566  ┆ 1   ┆ 0            ┆ 1996.0             │\n",
      "│ 7811543113991803283 ┆ 1623937648  ┆ 1   ┆ 0            ┆ 1996.0             │\n",
      "│ 6357221719449919802 ┆ 2064408433  ┆ 1   ┆ 0            ┆ 1750.0             │\n",
      "│ 6323188556852872827 ┆ -1817931181 ┆ 1   ┆ 0            ┆ 1996.0             │\n",
      "└─────────────────────┴─────────────┴─────┴──────────────┴────────────────────┘\n",
      "Q33 SELECT URL, COUNT(*) AS c FROM hits GROUP BY URL ORDER BY c DESC LIMIT 10;\n",
      "Pandas time: 7.771429538726807\n",
      "Pandas return:\n",
      "                                                  URL       c\n",
      "0                                http://kinopoisk.ru  141486\n",
      "1                   http://bdsm_po_yers=0&with_video   82623\n",
      "2  http://liver.ru/belgorod/page/1006.jки/доп_при...   78593\n",
      "3                        http://smeshariki.ru/region   59652\n",
      "4                         http://kinopoisk.ru/search   58276\n",
      "5                              http://tienskaia-moda   52965\n",
      "6                                http://video.yandex   47719\n",
      "7                http://kinopoisk.ru/vladimir.irr.ru   29715\n",
      "8             http://bjdleaks.php?produkty%2Fproduct   26809\n",
      "9                               http://pogoda.yandex   26589\n",
      "DuckDB time: 0.1876978874206543\n",
      "DuckDB return:\n",
      "                                                  URL       c\n",
      "0                                http://kinopoisk.ru  141486\n",
      "1                   http://bdsm_po_yers=0&with_video   82623\n",
      "2  http://liver.ru/belgorod/page/1006.jки/доп_при...   78593\n",
      "3                        http://smeshariki.ru/region   59652\n",
      "4                         http://kinopoisk.ru/search   58276\n",
      "5                              http://tienskaia-moda   52965\n",
      "6                                http://video.yandex   47719\n",
      "7                http://kinopoisk.ru/vladimir.irr.ru   29715\n",
      "8             http://bjdleaks.php?produkty%2Fproduct   26809\n",
      "9                               http://pogoda.yandex   26589\n",
      "chDB time: 0.21751952171325684\n",
      "chDB return:\n",
      " \"http://kinopoisk.ru\",141486\n",
      "\"http://bdsm_po_yers=0&with_video\",82623\n",
      "\"http://liver.ru/belgorod/page/1006.jки/доп_приборы\",78593\n",
      "\"http://smeshariki.ru/region\",59652\n",
      "\"http://kinopoisk.ru/search\",58276\n",
      "\"http://tienskaia-moda\",52965\n",
      "\"http://video.yandex\",47719\n",
      "\"http://kinopoisk.ru/vladimir.irr.ru\",29715\n",
      "\"http://bjdleaks.php?produkty%2Fproduct\",26809\n",
      "\"http://pogoda.yandex\",26589\n",
      "\n",
      "Polars time: 0.18122506141662598\n",
      "Polars return:\n",
      " shape: (10, 2)\n",
      "┌─────────────────────────────────┬────────┐\n",
      "│ URL                             ┆ c      │\n",
      "│ ---                             ┆ ---    │\n",
      "│ str                             ┆ u32    │\n",
      "╞═════════════════════════════════╪════════╡\n",
      "│ http://kinopoisk.ru             ┆ 141486 │\n",
      "│ http://bdsm_po_yers=0&with_vid… ┆ 82623  │\n",
      "│ http://liver.ru/belgorod/page/… ┆ 78593  │\n",
      "│ http://smeshariki.ru/region     ┆ 59652  │\n",
      "│ http://kinopoisk.ru/search      ┆ 58276  │\n",
      "│ http://tienskaia-moda           ┆ 52965  │\n",
      "│ http://video.yandex             ┆ 47719  │\n",
      "│ http://kinopoisk.ru/vladimir.i… ┆ 29715  │\n",
      "│ http://bjdleaks.php?produkty%2… ┆ 26809  │\n",
      "│ http://pogoda.yandex            ┆ 26589  │\n",
      "└─────────────────────────────────┴────────┘\n",
      "Q34 SELECT 1, URL, COUNT(*) AS c FROM hits GROUP BY 1, URL ORDER BY c DESC LIMIT 10;\n",
      "Pandas time: 7.3071815967559814\n",
      "Pandas return:\n",
      "                                                  URL       c\n",
      "0                                http://kinopoisk.ru  141486\n",
      "1                   http://bdsm_po_yers=0&with_video   82623\n",
      "2  http://liver.ru/belgorod/page/1006.jки/доп_при...   78593\n",
      "3                        http://smeshariki.ru/region   59652\n",
      "4                         http://kinopoisk.ru/search   58276\n",
      "5                              http://tienskaia-moda   52965\n",
      "6                                http://video.yandex   47719\n",
      "7                http://kinopoisk.ru/vladimir.irr.ru   29715\n",
      "8             http://bjdleaks.php?produkty%2Fproduct   26809\n",
      "9                               http://pogoda.yandex   26589\n",
      "DuckDB time: 0.18941712379455566\n",
      "DuckDB return:\n",
      "    1                                                URL       c\n",
      "0  1                                http://kinopoisk.ru  141486\n",
      "1  1                   http://bdsm_po_yers=0&with_video   82623\n",
      "2  1  http://liver.ru/belgorod/page/1006.jки/доп_при...   78593\n",
      "3  1                        http://smeshariki.ru/region   59652\n",
      "4  1                         http://kinopoisk.ru/search   58276\n",
      "5  1                              http://tienskaia-moda   52965\n",
      "6  1                                http://video.yandex   47719\n",
      "7  1                http://kinopoisk.ru/vladimir.irr.ru   29715\n",
      "8  1             http://bjdleaks.php?produkty%2Fproduct   26809\n",
      "9  1                               http://pogoda.yandex   26589\n",
      "chDB time: 0.19516444206237793\n",
      "chDB return:\n",
      " 1,\"http://kinopoisk.ru\",141486\n",
      "1,\"http://bdsm_po_yers=0&with_video\",82623\n",
      "1,\"http://liver.ru/belgorod/page/1006.jки/доп_приборы\",78593\n",
      "1,\"http://smeshariki.ru/region\",59652\n",
      "1,\"http://kinopoisk.ru/search\",58276\n",
      "1,\"http://tienskaia-moda\",52965\n",
      "1,\"http://video.yandex\",47719\n",
      "1,\"http://kinopoisk.ru/vladimir.irr.ru\",29715\n",
      "1,\"http://bjdleaks.php?produkty%2Fproduct\",26809\n",
      "1,\"http://pogoda.yandex\",26589\n",
      "\n",
      "Polars time: 0.172119140625\n",
      "Polars return:\n",
      " shape: (10, 2)\n",
      "┌─────────────────────────────────┬────────┐\n",
      "│ URL                             ┆ c      │\n",
      "│ ---                             ┆ ---    │\n",
      "│ str                             ┆ u32    │\n",
      "╞═════════════════════════════════╪════════╡\n",
      "│ http://kinopoisk.ru             ┆ 141486 │\n",
      "│ http://bdsm_po_yers=0&with_vid… ┆ 82623  │\n",
      "│ http://liver.ru/belgorod/page/… ┆ 78593  │\n",
      "│ http://smeshariki.ru/region     ┆ 59652  │\n",
      "│ http://kinopoisk.ru/search      ┆ 58276  │\n",
      "│ http://tienskaia-moda           ┆ 52965  │\n",
      "│ http://video.yandex             ┆ 47719  │\n",
      "│ http://kinopoisk.ru/vladimir.i… ┆ 29715  │\n",
      "│ http://bjdleaks.php?produkty%2… ┆ 26809  │\n",
      "│ http://pogoda.yandex            ┆ 26589  │\n",
      "└─────────────────────────────────┴────────┘\n",
      "Q35 SELECT ClientIP, ClientIP - 1, ClientIP - 2, ClientIP - 3, COUNT(*) AS c FROM hits GROUP BY ClientIP, ClientIP - 1, ClientIP - 2, ClientIP - 3 ORDER BY c DESC LIMIT 10;\n",
      "Pandas time: 32.501299142837524\n",
      "Pandas return:\n",
      "      ClientIP  ClientIP_minus_1  ClientIP_minus_2  ClientIP_minus_3      c\n",
      "0 -1698104457       -1698104458       -1698104459       -1698104460  15792\n",
      "1 -1175819552       -1175819553       -1175819554       -1175819555   6229\n",
      "2  1990169817        1990169816        1990169815        1990169814   6019\n",
      "3  1844870420        1844870419        1844870418        1844870417   6015\n",
      "4  1215815219        1215815218        1215815217        1215815216   4384\n",
      "5   -39921974         -39921975         -39921976         -39921977   3168\n",
      "6  1151807695        1151807694        1151807693        1151807692   2738\n",
      "7  1416368349        1416368348        1416368347        1416368346   2685\n",
      "8  1676284222        1676284221        1676284220        1676284219   2609\n",
      "9  1704860211        1704860210        1704860209        1704860208   2554\n",
      "DuckDB time: 0.10219049453735352\n",
      "DuckDB return:\n",
      "      ClientIP  (ClientIP - 1)  (ClientIP - 2)  (ClientIP - 3)      c\n",
      "0 -1698104457     -1698104458     -1698104459     -1698104460  15792\n",
      "1 -1175819552     -1175819553     -1175819554     -1175819555   6229\n",
      "2  1990169817      1990169816      1990169815      1990169814   6019\n",
      "3  1844870420      1844870419      1844870418      1844870417   6015\n",
      "4  1215815219      1215815218      1215815217      1215815216   4384\n",
      "5   -39921974       -39921975       -39921976       -39921977   3168\n",
      "6  1151807695      1151807694      1151807693      1151807692   2738\n",
      "7  1416368349      1416368348      1416368347      1416368346   2685\n",
      "8  1676284222      1676284221      1676284220      1676284219   2609\n",
      "9  1704860211      1704860210      1704860209      1704860208   2554\n",
      "chDB time: 0.08132767677307129\n",
      "chDB return:\n",
      " -1698104457,-1698104458,-1698104459,-1698104460,15792\n",
      "-1175819552,-1175819553,-1175819554,-1175819555,6229\n",
      "1990169817,1990169816,1990169815,1990169814,6019\n",
      "1844870420,1844870419,1844870418,1844870417,6015\n",
      "1215815219,1215815218,1215815217,1215815216,4384\n",
      "-39921974,-39921975,-39921976,-39921977,3168\n",
      "1151807695,1151807694,1151807693,1151807692,2738\n",
      "1416368349,1416368348,1416368347,1416368346,2685\n",
      "1676284222,1676284221,1676284220,1676284219,2609\n",
      "1704860211,1704860210,1704860209,1704860208,2554\n",
      "\n",
      "Polars time: 0.06913375854492188\n",
      "Polars return:\n",
      " shape: (10, 2)\n",
      "┌─────────────┬───────┐\n",
      "│ ClientIP    ┆ c     │\n",
      "│ ---         ┆ ---   │\n",
      "│ i32         ┆ u32   │\n",
      "╞═════════════╪═══════╡\n",
      "│ -1698104457 ┆ 15792 │\n",
      "│ -1175819552 ┆ 6229  │\n",
      "│ 1990169817  ┆ 6019  │\n",
      "│ 1844870420  ┆ 6015  │\n",
      "│ 1215815219  ┆ 4384  │\n",
      "│ -39921974   ┆ 3168  │\n",
      "│ 1151807695  ┆ 2738  │\n",
      "│ 1416368349  ┆ 2685  │\n",
      "│ 1676284222  ┆ 2609  │\n",
      "│ 1704860211  ┆ 2554  │\n",
      "└─────────────┴───────┘\n",
      "Q36 SELECT URL, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND DontCountHits = 0 AND IsRefresh = 0 AND URL <> '' GROUP BY URL ORDER BY PageViews DESC LIMIT 10;\n",
      "Pandas time: 0.7082381248474121\n",
      "Pandas return:\n",
      " URL\n",
      "http://irr.ru/index.php?showalbum/login-leniya7777294,938303130             15378\n",
      "http://komme%2F27.0.1453.116                                                 6942\n",
      "http://irr.ru/index.php?showalbum/login-kapusta-advert2668]=0&order_by=0     2546\n",
      "http://irr.ru/index.php?showalbum/login-kapustic/product_name                2131\n",
      "http://irr.ru/index.php?showalbum/login                                      1574\n",
      "http://irr.ru/index.php                                                      1550\n",
      "http://komme%2F27.0.1453.116 Safari%2F5.0 (compatible; MSIE 9.0;             1045\n",
      "http://irr.ru/index.php?showalbum/login-kupalnik                              593\n",
      "http://komme%2F27.0.1453.116 Safari                                           517\n",
      "http://irr.ru/index.php?showalbum/login-kapusta-advert27256.html_params       511\n",
      "dtype: int64\n",
      "DuckDB time: 0.05800819396972656\n",
      "DuckDB return:\n",
      "                                                  URL  PageViews\n",
      "0  http://irr.ru/index.php?showalbum/login-leniya...      15378\n",
      "1                       http://komme%2F27.0.1453.116       6942\n",
      "2  http://irr.ru/index.php?showalbum/login-kapust...       2546\n",
      "3  http://irr.ru/index.php?showalbum/login-kapust...       2131\n",
      "4            http://irr.ru/index.php?showalbum/login       1574\n",
      "5                            http://irr.ru/index.php       1550\n",
      "6  http://komme%2F27.0.1453.116 Safari%2F5.0 (com...       1045\n",
      "7   http://irr.ru/index.php?showalbum/login-kupalnik        593\n",
      "8                http://komme%2F27.0.1453.116 Safari        517\n",
      "9  http://irr.ru/index.php?showalbum/login-kapust...        511\n",
      "chDB time: 0.10596656799316406\n",
      "chDB return:\n",
      " \"http://irr.ru/index.php?showalbum/login-leniya7777294,938303130\",15378\n",
      "\"http://komme%2F27.0.1453.116\",6942\n",
      "\"http://irr.ru/index.php?showalbum/login-kapusta-advert2668]=0&order_by=0\",2546\n",
      "\"http://irr.ru/index.php?showalbum/login-kapustic/product_name\",2131\n",
      "\"http://irr.ru/index.php?showalbum/login\",1574\n",
      "\"http://irr.ru/index.php\",1550\n",
      "\"http://komme%2F27.0.1453.116 Safari%2F5.0 (compatible; MSIE 9.0;\",1045\n",
      "\"http://irr.ru/index.php?showalbum/login-kupalnik\",593\n",
      "\"http://komme%2F27.0.1453.116 Safari\",517\n",
      "\"http://irr.ru/index.php?showalbum/login-kapusta-advert27256.html_params\",511\n",
      "\n",
      "Polars time: 2.07474422454834\n",
      "Polars return:\n",
      " shape: (10, 2)\n",
      "┌─────────────────────────────────┬───────────┐\n",
      "│ URL                             ┆ PageViews │\n",
      "│ ---                             ┆ ---       │\n",
      "│ str                             ┆ u32       │\n",
      "╞═════════════════════════════════╪═══════════╡\n",
      "│ http://irr.ru/index.php?showal… ┆ 15378     │\n",
      "│ http://komme%2F27.0.1453.116    ┆ 6942      │\n",
      "│ http://irr.ru/index.php?showal… ┆ 2546      │\n",
      "│ http://irr.ru/index.php?showal… ┆ 2131      │\n",
      "│ http://irr.ru/index.php?showal… ┆ 1574      │\n",
      "│ http://irr.ru/index.php         ┆ 1550      │\n",
      "│ http://komme%2F27.0.1453.116 S… ┆ 1045      │\n",
      "│ http://irr.ru/index.php?showal… ┆ 593       │\n",
      "│ http://komme%2F27.0.1453.116 S… ┆ 517       │\n",
      "│ http://irr.ru/index.php?showal… ┆ 511       │\n",
      "└─────────────────────────────────┴───────────┘\n",
      "Q37 SELECT Title, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND DontCountHits = 0 AND IsRefresh = 0 AND Title <> '' GROUP BY Title ORDER BY PageViews DESC LIMIT 10;\n",
      "Pandas time: 0.6800808906555176\n",
      "Pandas return:\n",
      " Title\n",
      "Тест (Россия) - Яндекс                                                  18486\n",
      "Шарарай), Выбрать! - обсуждаются на голд: Шоубиз - Свободная историс    11533\n",
      "Приморск - IRR.ru                                                       10785\n",
      "Брюки New Era H (Асус) 258 общая выплаток, горшечными                    5916\n",
      "Теплоску на                                                              2997\n",
      "Dave and Hotpoint sport – самые вещие                                    2283\n",
      "AUTO.ria.ua ™ - Аппер                                                    1835\n",
      "OWAProfessign), продать                                                  1828\n",
      "Приморск (Россия) - Яндекс.Видео                                         1781\n",
      "бассе» внутренчкоты                                                      1464\n",
      "dtype: int64\n",
      "DuckDB time: 0.1615283489227295\n",
      "DuckDB return:\n",
      "                                                Title  PageViews\n",
      "0                             Тест (Россия) - Яндекс      18486\n",
      "1  Шарарай), Выбрать! - обсуждаются на голд: Шоуб...      11533\n",
      "2                                  Приморск - IRR.ru      10785\n",
      "3  Брюки New Era H (Асус) 258 общая выплаток, гор...       5916\n",
      "4                                        Теплоску на       2997\n",
      "5              Dave and Hotpoint sport – самые вещие       2283\n",
      "6                              AUTO.ria.ua ™ - Аппер       1835\n",
      "7                            OWAProfessign), продать       1828\n",
      "8                   Приморск (Россия) - Яндекс.Видео       1781\n",
      "9                               бассе» внутренчкоты        1464\n",
      "chDB time: 0.14129924774169922\n",
      "chDB return:\n",
      " \"Тест (Россия) - Яндекс\",18486\n",
      "\"Шарарай), Выбрать! - обсуждаются на голд: Шоубиз - Свободная историс\",11533\n",
      "\"Приморск - IRR.ru\",10785\n",
      "\"Брюки New Era H (Асус) 258 общая выплаток, горшечными\",5916\n",
      "\"Теплоску на\",2997\n",
      "\"Dave and Hotpoint sport – самые вещие\",2283\n",
      "\"AUTO.ria.ua ™ - Аппер\",1835\n",
      "\"OWAProfessign), продать\",1828\n",
      "\"Приморск (Россия) - Яндекс.Видео\",1781\n",
      "\"бассе» внутренчкоты \",1464\n",
      "\n",
      "Polars time: 1.865403413772583\n",
      "Polars return:\n",
      " shape: (10, 2)\n",
      "┌─────────────────────────────────┬───────────┐\n",
      "│ Title                           ┆ PageViews │\n",
      "│ ---                             ┆ ---       │\n",
      "│ str                             ┆ u32       │\n",
      "╞═════════════════════════════════╪═══════════╡\n",
      "│ Тест (Россия) - Яндекс          ┆ 18486     │\n",
      "│ Шарарай), Выбрать! - обсуждают… ┆ 11533     │\n",
      "│ Приморск - IRR.ru               ┆ 10785     │\n",
      "│ Брюки New Era H (Асус) 258 общ… ┆ 5916      │\n",
      "│ Теплоску на                     ┆ 2997      │\n",
      "│ Dave and Hotpoint sport – самы… ┆ 2283      │\n",
      "│ AUTO.ria.ua ™ - Аппер           ┆ 1835      │\n",
      "│ OWAProfessign), продать         ┆ 1828      │\n",
      "│ Приморск (Россия) - Яндекс.Вид… ┆ 1781      │\n",
      "│ бассе» внутренчкоты             ┆ 1464      │\n",
      "└─────────────────────────────────┴───────────┘\n",
      "Q38 SELECT URL, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND IsRefresh = 0 AND IsLink <> 0 AND IsDownload = 0 GROUP BY URL ORDER BY PageViews DESC LIMIT 10 OFFSET 1000;\n",
      "Pandas time: 0.05269670486450195\n",
      "Pandas return:\n",
      " Empty DataFrame\n",
      "Columns: [URL, PageViews]\n",
      "Index: []\n",
      "DuckDB time: 0.04982304573059082\n",
      "DuckDB return:\n",
      "                                                  URL  PageViews\n",
      "0  http://netcatalog/0/search/?q=подростойка-стре...          1\n",
      "1  http://stalker-pub-20087898675494,960948/#page...          1\n",
      "2                             https://mr7.ru/catalog          1\n",
      "3  http://stalker-pub-20087898675494,960948/#page...          1\n",
      "4                   http://bdsmpeople.ru/search?text          1\n",
      "5  http://stalker-pub-20087898675494,960948/#page...          1\n",
      "6                                http://povarenok.ru          1\n",
      "7  http://wildberries.aspx#location/group_cod_1s=...          1\n",
      "8  http://stalker-pub-20087898675494,960948/#page...          1\n",
      "9  http://stalker-pub-20087898675494,960948/#page...          1\n",
      "chDB time: 0.12198710441589355\n",
      "chDB return:\n",
      " \"http://wildberries.aspx#location/group_cod_1s=53&butto_638_1360/3/women.aspx?group_cod_1s=8577/~7/?cauth=0&color=0&auto_ria=0&type\",1\n",
      "\"http://stalker-pub-20087898675494,960948/#page_type%3D0%26pz%3D0%26rleurl%3D//ad.adriver.ru/photo=0&is_hot=0&auto_id=577&oki=1&op_prodam-1-komn-kvarti-m.ru/allprice/arts-total=больше 100 до 1500&price_do=50\",1\n",
      "\"http://stalker-pub-20087898675494,960948/#page_type%3D0%26pz%3D0%26rleurl%3D%26xpid%3D158197%26anbieter%3DYandex.ru/novosibirsk-gorjache/wm/2013-07-29#sched_car=364499cnD0Ril3dX-UhABIABQgMfhxARghOXxhbAewCl55A%26uid\",1\n",
      "\"http://bibidohertki--962845.html?locatid,14.20\",1\n",
      "\"http://stalker-pub-20087898675494,960948/#page_type%3D260117152337&spn=1395,94552/photo-3.xhtml?&ss=1&ru=1&expand_seasons/lg/?area/frl-2/bags.spinningradex\",1\n",
      "\"http://afisha.yandex.ru/Web/price=меньше 19876/kseniye-rebenok\",1\n",
      "\"http://stalker-pub-20087898675494,960948/#page_type%3D0%26pz%3D0%26rleurl%3D%26CompPath%3D278885%26bid%3D0%26u_h%3D728%26fh_page=1080&with_exchangeTypeId=0&engineVolumeTo=&fuelRatesType=0&mode=Отправлик темно\",1\n",
      "\"http://stalker-pub-20087898675494,960948/#page_type%3D260117152337&spn=1395,9455989.ya.ru/world/photo/hair_appleWebKit%2F5.0 (Windows NT 6.1; WOW64; Tridential/Volkswagen_liver.ru/catalog/topic,8081e.21152007881277.0&he=768&wi=13625857912233596767_dumalu\",1\n",
      "\"http://stalker-pub-20087898675494,960948/#page_type%3D260117152337&spn=1395,9455989.ya.ru/world/photo=1&search?text=маша грибыльские приборы&ch=utf-8&sF=11,7,700&aN=Netscape&aV=9.80 (Windole.ru/cinema/artiru-Podgotovim-doma.ru/real\",1\n",
      "\"http://stalker-pub-20087898675494,960948/#page_type%3D260117152337&spn=1395,9455989.ya.ru/workman/krasnodar.pulscen.ru/bios.html5/v12/?from]=&int[153][from]=&input_city=0&page=4&marka=0&po_yers=20073192641#/view_type%3D0%26aktion/russinsk/details/?cat_number\",1\n",
      "\n",
      "Polars time: 0.726616382598877\n",
      "Polars return:\n",
      " shape: (10, 2)\n",
      "┌─────────────────────────────────┬───────────┐\n",
      "│ URL                             ┆ PageViews │\n",
      "│ ---                             ┆ ---       │\n",
      "│ str                             ┆ u32       │\n",
      "╞═════════════════════════════════╪═══════════╡\n",
      "│ http://stalker-pub-20087898675… ┆ 1         │\n",
      "│ http://smeshariki.ru/cated_cou… ┆ 1         │\n",
      "│ http://wildberries.aspx#locati… ┆ 1         │\n",
      "│ http://stalker-pub-20087898675… ┆ 1         │\n",
      "│ http://wildberries.aspx#locati… ┆ 1         │\n",
      "│ http://stalker-pub-20087898675… ┆ 1         │\n",
      "│ http://maps#ru_5_ru_227_ru_363… ┆ 1         │\n",
      "│ http://stalker-pub-20087898675… ┆ 1         │\n",
      "│ http://stalker-pub-20087898675… ┆ 1         │\n",
      "│ http://irr.ru/index.php?showal… ┆ 1         │\n",
      "└─────────────────────────────────┴───────────┘\n",
      "Q39 SELECT TraficSourceID, SearchEngineID, AdvEngineID, CASE WHEN (SearchEngineID = 0 AND AdvEngineID = 0) THEN Referer ELSE '' END AS Src, URL AS Dst, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND IsRefresh = 0 GROUP BY TraficSourceID, SearchEngineID, AdvEngineID, Src, Dst ORDER BY PageViews DESC LIMIT 10 OFFSET 1000;\n",
      "Pandas time: 0.654062032699585\n",
      "Pandas return:\n",
      " Empty DataFrame\n",
      "Columns: [TraficSourceID, SearchEngineID, AdvEngineID, Referer, URL, PageViews]\n",
      "Index: []\n",
      "DuckDB time: 0.13443231582641602\n",
      "DuckDB return:\n",
      "    TraficSourceID  SearchEngineID  AdvEngineID  \\\n",
      "0              -1               0            0   \n",
      "1              -1               0            0   \n",
      "2               0               0            0   \n",
      "3              -1               0            0   \n",
      "4              -1               0            0   \n",
      "5               3               4            0   \n",
      "6              -1               0            0   \n",
      "7               1               0            0   \n",
      "8              -1               0            0   \n",
      "9              -1               0            0   \n",
      "\n",
      "                                                 Src  \\\n",
      "0                         http://kinopoisk.ru/?state   \n",
      "1  http://state=19945206/foto-4/login-2006/makumi...   \n",
      "2                                                      \n",
      "3  http://state=19945206/foto-4/login-2491724/?bu...   \n",
      "4  http://state=19945206/foto-4/login-2491724/?bu...   \n",
      "5                                                      \n",
      "6  http://state=19945206/foto-4/login-2491724/?bu...   \n",
      "7           http://kinopoisk.ru/offer/rative-english   \n",
      "8  http://state=19945206/foto-4/login-2491724/?bu...   \n",
      "9  http://state=19945206/foto-4/login-2006/makumi...   \n",
      "\n",
      "                                                 Dst  PageViews  \n",
      "0  http://irr.ru/index.php?showalbum/login-kapust...          5  \n",
      "1  http://irr.ru/index.php?showalbum/login-leniya...          5  \n",
      "2  http://irr.ru/index.php?showalbum/login-kapust...          5  \n",
      "3  http://irr.ru/index.php?showalbum/login-tatars...          5  \n",
      "4  http://irr.ru/index.php?showalbum/login-kapust...          5  \n",
      "5                       http://komme%2F27.0.1453.116          5  \n",
      "6  http://irr.ru/index.php?showalbum/login-kapust...          5  \n",
      "7  http://komme%2F27.0.1453.116 Safari%2F5.0 (com...          5  \n",
      "8  http://irr.ru/index.php?showalbum/login-kapust...          5  \n",
      "9  http://irr.ru/index.php?showalbum/login-leniya...          5  \n",
      "chDB time: 0.1535947322845459\n",
      "chDB return:\n",
      " -1,0,0,\"http://state=19945206/foto-4/login-2491724/?bundlers/search?text\",\"http://irr.ru/index.php?showalbum/login-kapusta-advert2760798712/27000&categoriya%2Ffieiiervices\",5\n",
      "0,0,0,\"\",\"http://irr.ru/index.php?showalbum/login-kapusta-advert278888885%26bn%3D0%26ad%3D2%26nid%3DBSf_Y\",5\n",
      "-1,0,0,\"http://state=19945206/foto-4/login-2006/makumirostova.rambler.ru/malding_max=250&sz=waterior\",\"http://irr.ru/index.php?showalbum/login-kapusta-advert2631920&lo=http:%2F%2Fwwww\",5\n",
      "-1,0,0,\"http://state=19945206/foto-4/login-bikini-02-19458%26key%3D72673810274&price=1&wr=0&matchen/перевосход\",\"http://irr.ru/index.php?showalbum/login-kapustic/product_name\",5\n",
      "0,0,0,\"\",\"http://irr.ru/index.php?showalbum/login-kapusta-advert2792648/?cat=55.01.2013-07-04/2/womenskaia\",5\n",
      "-1,0,0,\"http://state=19945206/foto-4/login-kurtka-album/loginInvNww&bvm=bv.48705608,d.bGE&cad=rja&sqi=2&ved=0CDoQFjAA&url=http://saint-petersburg and togets/yandex.ru/Web/PageSplit=&isgray=KW&marka=23&parking_card-2.aspx?group\",\"http://irr.ru/index.php?showalbum/login-kapusta-advert2728549/region=308#postered/main.asp?dom=5009\",5\n",
      "-1,0,0,\"http://state=19945206/foto-4/login-2006/makumirosomahachka/saledParam\",\"http://irr.ru/index.php?showalbum/login-kapusta-advert26930&pt=b&pd=6&pvno=2&evlg=VC,6;VL,235,0\",5\n",
      "5,0,0,\"http://kinopoisk.ru/?state\",\"http://lib.ru/exp?sid=3205&bt=7&bn\",5\n",
      "-1,0,0,\"http://state=19945206/foto-4/login_airbag=&source=web&cd=1&ved=0CC4QFjABOAo&url=http://yands][0]=смали из шоу смотреть онлайн 2013-06-00-0/0/movie//holodilnik.ru/catalog/2894/page37/?date&y1=20&text=словинки на дачу&source=web&cd=4&maxpriceMax=20000 до 5000&price=&all=1&redirect.yandex.ru/user=asc&pagead/ads/sanitary_id=0&only_owners=0&price=от 14003119c05cb506bb0af0b7e4d46345f3666&price=&built_info/node/226595?analogmineer.ru/real-estate/rent/page2/add/adset=userrova71\",\"http://irr.ru/index.php?showalbum/login&tag=video.yandex.ru/regular&bid=3205&bt=7&bn=1&bc=3&ct=1&pr=4433714.last_autodoc.ru/sort=actures/year=2&auto_id=1156&station&op_product&op_product_brand=BODYFLIRT - bonprix.ru/filmId=5MBbVszf9xc&where=all&text=нло аллак.html%3Fhtml?1=1&cmguide.trashbox.ru/search/d-1/foto.ashx/1014;IC,4896991269.html%3Fhtml?brand=bpc bonprix.ru/ency=1#country=&op_page1=18&model.ru/search?text&section=20268639709948.html?1=1&cid=577&oki=1\",5\n",
      "-1,0,0,\"http://state=19945206/foto-4/login-2006/makumirostova.ru/cars/passe/1/2/men/waterinburg.irr\",\"http://irr.ru/index.php?showalbum/login-leniya7777294,938303130\",5\n",
      "\n",
      "Polars time: 9.5367431640625e-07\n",
      "Polars return:\n",
      " None\n",
      "Q40 SELECT URLHash, EventDate, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND IsRefresh = 0 AND TraficSourceID IN (-1, 6) AND RefererHash = 3594120000172545465 GROUP BY URLHash, EventDate ORDER BY PageViews DESC LIMIT 10 OFFSET 100;\n",
      "Pandas time: 0.14491891860961914\n",
      "Pandas return:\n",
      " Empty DataFrame\n",
      "Columns: [URLHash, EventDate, PageViews]\n",
      "Index: []\n",
      "DuckDB time: 0.05103349685668945\n",
      "DuckDB return:\n",
      "                URLHash  EventDate  PageViews\n",
      "0 -1802686817589810185 2013-07-15         10\n",
      "1 -2136824408703480407 2013-07-15         10\n",
      "2 -2900068695914218823 2013-07-15         10\n",
      "3 -3334426674884931276 2013-07-15         10\n",
      "4  7745798256146114954 2013-07-15         10\n",
      "5  5607000794197120606 2013-07-15         10\n",
      "6  6873670041144843393 2013-07-15         10\n",
      "7   650616115218363097 2013-07-15         10\n",
      "8 -7564973518176820847 2013-07-15         10\n",
      "9 -5974687391226976818 2013-07-15         10\n",
      "chDB time: 0.07001781463623047\n",
      "chDB return:\n",
      " 650616115218363097,\"2013-07-15 08:00:00.000000000\",10\n",
      "1518554308732023915,\"2013-07-15 08:00:00.000000000\",10\n",
      "1285560673132798759,\"2013-07-15 08:00:00.000000000\",10\n",
      "-7564973518176820847,\"2013-07-15 08:00:00.000000000\",10\n",
      "5607000794197120606,\"2013-07-15 08:00:00.000000000\",10\n",
      "7459640648655452865,\"2013-07-15 08:00:00.000000000\",10\n",
      "7745798256146114954,\"2013-07-15 08:00:00.000000000\",10\n",
      "-3451071041994192989,\"2013-07-15 08:00:00.000000000\",10\n",
      "-573217089863865205,\"2013-07-15 08:00:00.000000000\",10\n",
      "5533436450043627195,\"2013-07-15 08:00:00.000000000\",10\n",
      "\n",
      "Polars time: 0.23132848739624023\n",
      "Polars return:\n",
      " shape: (10, 3)\n",
      "┌──────────────────────┬─────────────────────┬───────────┐\n",
      "│ URLHash              ┆ EventDate           ┆ PageViews │\n",
      "│ ---                  ┆ ---                 ┆ ---       │\n",
      "│ i64                  ┆ datetime[ns]        ┆ u32       │\n",
      "╞══════════════════════╪═════════════════════╪═══════════╡\n",
      "│ 9117416179998756751  ┆ 2013-07-15 00:00:00 ┆ 10        │\n",
      "│ 6061487698837678125  ┆ 2013-07-15 00:00:00 ┆ 10        │\n",
      "│ 1518554308732023915  ┆ 2013-07-15 00:00:00 ┆ 10        │\n",
      "│ 2465537114496173148  ┆ 2013-07-15 00:00:00 ┆ 10        │\n",
      "│ -2900068695914218823 ┆ 2013-07-15 00:00:00 ┆ 10        │\n",
      "│ 5533436450043627195  ┆ 2013-07-15 00:00:00 ┆ 10        │\n",
      "│ -1802686817589810185 ┆ 2013-07-15 00:00:00 ┆ 10        │\n",
      "│ 7459640648655452865  ┆ 2013-07-15 00:00:00 ┆ 10        │\n",
      "│ -3334426674884931276 ┆ 2013-07-15 00:00:00 ┆ 10        │\n",
      "│ 6873670041144843393  ┆ 2013-07-15 00:00:00 ┆ 10        │\n",
      "└──────────────────────┴─────────────────────┴───────────┘\n",
      "Q41 SELECT WindowClientWidth, WindowClientHeight, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND IsRefresh = 0 AND DontCountHits = 0 AND URLHash = 2868770270353813622 GROUP BY WindowClientWidth, WindowClientHeight ORDER BY PageViews DESC LIMIT 10 OFFSET 10000;\n",
      "Pandas time: 0.07189512252807617\n",
      "Pandas return:\n",
      " Empty DataFrame\n",
      "Columns: [WindowClientWidth, WindowClientHeight, PageViews]\n",
      "Index: []\n",
      "DuckDB time: 0.05136418342590332\n",
      "DuckDB return:\n",
      " Empty DataFrame\n",
      "Columns: [WindowClientWidth, WindowClientHeight, PageViews]\n",
      "Index: []\n",
      "chDB time: 0.06618666648864746\n",
      "chDB return:\n",
      " \n",
      "Polars time: 0.0189208984375\n",
      "Polars return:\n",
      " shape: (0, 3)\n",
      "┌───────────────────┬────────────────────┬───────────┐\n",
      "│ WindowClientWidth ┆ WindowClientHeight ┆ PageViews │\n",
      "│ ---               ┆ ---                ┆ ---       │\n",
      "│ i16               ┆ i16                ┆ u32       │\n",
      "╞═══════════════════╪════════════════════╪═══════════╡\n",
      "└───────────────────┴────────────────────┴───────────┘\n",
      "Q42 SELECT DATE_TRUNC('minute', EventTime) AS M, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-14' AND EventDate <= '2013-07-15' AND IsRefresh = 0 AND DontCountHits = 0 GROUP BY DATE_TRUNC('minute', EventTime) ORDER BY DATE_TRUNC('minute', EventTime) LIMIT 10 OFFSET 1000;\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_873169/4080565043.py:731: FutureWarning: 'T' is deprecated and will be removed in a future version, please use 'min' instead.\n",
      "  .groupby(pd.Grouper(key=\"EventTime\", freq=\"T\"))\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Pandas time: 0.18853545188903809\n",
      "Pandas return:\n",
      "                EventTime  PageViews\n",
      "1000 2013-07-15 12:40:00         59\n",
      "1001 2013-07-15 12:41:00         57\n",
      "1002 2013-07-15 12:42:00         77\n",
      "1003 2013-07-15 12:43:00         56\n",
      "1004 2013-07-15 12:44:00         46\n",
      "1005 2013-07-15 12:45:00         51\n",
      "1006 2013-07-15 12:46:00         62\n",
      "1007 2013-07-15 12:47:00         90\n",
      "1008 2013-07-15 12:48:00         90\n",
      "1009 2013-07-15 12:49:00         80\n",
      "DuckDB time: 0.05023622512817383\n",
      "DuckDB return:\n",
      "                     M  PageViews\n",
      "0 2013-07-15 12:40:00         59\n",
      "1 2013-07-15 12:41:00         57\n",
      "2 2013-07-15 12:42:00         77\n",
      "3 2013-07-15 12:43:00         56\n",
      "4 2013-07-15 12:44:00         46\n",
      "5 2013-07-15 12:45:00         51\n",
      "6 2013-07-15 12:46:00         62\n",
      "7 2013-07-15 12:47:00         90\n",
      "8 2013-07-15 12:48:00         90\n",
      "9 2013-07-15 12:49:00         80\n",
      "chDB time: 0.052018165588378906\n",
      "chDB return:\n",
      " \n",
      "Polars time: 9.5367431640625e-07\n",
      "Polars return:\n",
      " None\n"
     ]
    }
   ],
   "source": [
    "# Run the benchmark!\n",
    "# Benchmark results\n",
    "duckdb_times = []\n",
    "chdb_times = []\n",
    "pandas_times = []\n",
    "polars_times = []\n",
    "\n",
    "counter = 0\n",
    "for q in queries:\n",
    "    duckdb_time, chdb_time, pandas_time, polars_time = bench(q, N=1)\n",
    "\n",
    "    duckdb_times.append(duckdb_time)\n",
    "    chdb_times.append(chdb_time)\n",
    "    pandas_times.append(pandas_time)\n",
    "    polars_times.append(polars_time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\"DuckDB\": [[0.03433990478515625], [0.026508569717407227], [0.02513861656188965], [0.021852970123291016], [0.07819533348083496], [0.08364367485046387], [0.024533987045288086], [0.046100616455078125], [0.09088969230651855], [0.12663817405700684], [0.052741050720214844], [0.0588836669921875], [0.09914731979370117], [0.1588895320892334], [0.10474276542663574], [0.08089947700500488], [0.14031195640563965], [0.14226555824279785], [0.2024822235107422], [0.02909088134765625], [0.12494659423828125], [0.12578415870666504], [0.23342061042785645], [0.47556400299072266], [0.1318378448486328], [0.2535984516143799], [0.18941974639892578], [0.1553800106048584], [0.5170934200286865], [0.20304656028747559], [0.08614468574523926], [0.10591721534729004], [0.20980262756347656], [0.1876978874206543], [0.18941712379455566], [0.10219049453735352], [0.05800819396972656], [0.1615283489227295], [0.04982304573059082], [0.13443231582641602], [0.05103349685668945], [0.05136418342590332], [0.05023622512817383]], \"chDB\": [[0.06516456604003906], [0.027498722076416016], [0.02389240264892578], [0.026594877243041992], [0.18276023864746094], [0.1492304801940918], [0.025769948959350586], [0.054378509521484375], [0.08289217948913574], [0.09233450889587402], [0.09442925453186035], [0.05849885940551758], [0.12346029281616211], [0.11397171020507812], [0.10899591445922852], [0.08938097953796387], [0.15292119979858398], [0.1154947280883789], [0.195556640625], [0.023262739181518555], [0.08678507804870605], [0.11338138580322266], [0.18370819091796875], [0.4304678440093994], [0.0423429012298584], [0.03441929817199707], [0.046121835708618164], [0.14062786102294922], [0.2968788146972656], [0.05274057388305664], [0.06468677520751953], [0.09296727180480957], [0.20761418342590332], [0.21751952171325684], [0.19516444206237793], [0.08132767677307129], [0.10596656799316406], [0.14129924774169922], [0.12198710441589355], [0.1535947322845459], [0.07001781463623047], [0.06618666648864746], [0.052018165588378906]], \"Pandas\": [[8.789468765258789], [0.16229581832885742], [0.007686138153076172], [0.007529735565185547], [0.21137714385986328], [0.6686234474182129], [0.02013540267944336], [0.07054853439331055], [0.5789997577667236], [0.6821517944335938], [0.839637279510498], [0.8696815967559814], [2.7713074684143066], [2.760340929031372], [8.411752223968506], [0.7016208171844482], [25.73132586479187], [2.7518060207366943], [54.36725902557373], [0.0063283443450927734], [2.1297006607055664], [2.5472168922424316], [8.950557470321655], [2.123731851577759], [2.3252789974212646], [3.9367663860321045], [4.12407112121582], [11.973230361938477], [30.965622425079346], [2.758824586868286], [1.535578966140747], [1.996917963027954], [7.862155199050903], [7.771429538726807], [7.3071815967559814], [32.501299142837524], [0.7082381248474121], [0.6800808906555176], [0.05269670486450195], [0.654062032699585], [0.14491891860961914], [0.07189512252807617], [0.18853545188903809]], \"Polars\": [[1.6450881958007812e-05], [0.02317357063293457], [0.03767538070678711], [0.004158496856689453], [0.13331985473632812], [0.3041989803314209], [0.00613856315612793], [0.027820348739624023], [0.2607238292694092], [0.24764204025268555], [0.12893366813659668], [0.1208345890045166], [0.19979619979858398], [22.400670289993286], [0.18914175033569336], [0.12315940856933594], [0.2002735137939453], [0.11278939247131348], [0.4637932777404785], [0.006215810775756836], [0.18349432945251465], [0.18537497520446777], [0.36249494552612305], [0.18419170379638672], [0.27924275398254395], [0.2817411422729492], [0.2635948657989502], [0.8907685279846191], [6.252786636352539], [0.0001652240753173828], [0.24605369567871094], [0.2792203426361084], [0.5795397758483887], [0.18122506141662598], [0.172119140625], [0.06913375854492188], [2.07474422454834], [1.865403413772583], [0.726616382598877], [null], [0.23132848739624023], [0.0189208984375], [null]]}\n"
     ]
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import json\n",
    "\n",
    "data_map = {\n",
    "    \"DuckDB\": duckdb_times,\n",
    "    \"chDB\": chdb_times,\n",
    "    \"Pandas\": pandas_times,\n",
    "    \"Polars\": polars_times,\n",
    "}\n",
    "print(json.dumps(data_map))\n",
    "\n",
    "data_tpl = {\"system\": None,\"date\":\"2024-02-05\",\"machine\":\"EPYC 9654, 128G, 4TB\",\"cluster_size\":1,\"tags\":[\"C++\",\"column-oriented\",\"Pandas Compatible\"],\"load_time\":0,\"data_size\":922699018,\"result\": None,\"source\":\"\"}\n",
    "\n",
    "data_to_render = []\n",
    "for k, v in data_map.items():\n",
    "    data = data_tpl.copy()\n",
    "    data[\"system\"] = k\n",
    "    data[\"result\"] = v\n",
    "    data[\"date\"] = datetime.datetime.now().strftime(\"%Y-%m-%d\")\n",
    "    if k == \"Polars\":\n",
    "        data[\"load_time\"] = pl_load_time\n",
    "    data_to_render.append(data)\n",
    "\n",
    "with open(\"/auxten/chdb/benchmark/cb_index.html.tpl\", \"r\") as f:\n",
    "    html = f.read()\n",
    "    html = html.replace(\"DATA_PLACEHOLDER\", f\"const data = {json.dumps(data_to_render)};\")\n",
    "    with open(\"/auxten/chdb/benchmark/cb_index.html\", \"w\") as f:\n",
    "        f.write(html)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
